{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "[![Dataflowr](https://raw.githubusercontent.com/dataflowr/website/master/_assets/dataflowr_logo.png)](https://dataflowr.github.io/website/)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "CUiFyiXKHovB"
   },
   "source": [
    "# [Module 6](https://dataflowr.github.io/website/modules/6-convolutional-neural-network/): Convolutions by examples\n",
    "\n",
    "We'll build our first Convolutional Neural Network (CNN) from scratch."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "7v7DN_UKHovE"
   },
   "source": [
    "## 1. Preparations"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "eQmaHvupHovF"
   },
   "outputs": [],
   "source": [
    "%matplotlib inline\n",
    "import math,sys,os,numpy as np\n",
    "from numpy.linalg import norm\n",
    "from matplotlib import pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "lkRdumG1HovK"
   },
   "outputs": [],
   "source": [
    "import torch\n",
    "import torchvision\n",
    "from torchvision import models,transforms,datasets"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "3JlQUj5IHovP"
   },
   "source": [
    "Download MNIST data on disk and convert it to pytorch compatible formatting.\n",
    "\n",
    "```torchvision.datasets``` features support (download, formatting) for a collection of popular datasets. The list of available datasets in ```torchvision``` can be found [here](http://pytorch.org/docs/master/torchvision/datasets.html).\n",
    "\n",
    "Note that the download is performed only once. The function will always check first if the data is already on disk.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "Bv9h8isvHovQ"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Downloading http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz\n",
      "Downloading http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz to ./data/MNIST/MNIST/raw/train-images-idx3-ubyte.gz\n"
     ]
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "  0%|          | 0/9912422 [00:00<?, ?it/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Extracting ./data/MNIST/MNIST/raw/train-images-idx3-ubyte.gz to ./data/MNIST/MNIST/raw\n",
      "\n",
      "Downloading http://yann.lecun.com/exdb/mnist/train-labels-idx1-ubyte.gz\n",
      "Downloading http://yann.lecun.com/exdb/mnist/train-labels-idx1-ubyte.gz to ./data/MNIST/MNIST/raw/train-labels-idx1-ubyte.gz\n"
     ]
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "  0%|          | 0/28881 [00:00<?, ?it/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Extracting ./data/MNIST/MNIST/raw/train-labels-idx1-ubyte.gz to ./data/MNIST/MNIST/raw\n",
      "\n",
      "Downloading http://yann.lecun.com/exdb/mnist/t10k-images-idx3-ubyte.gz\n",
      "Downloading http://yann.lecun.com/exdb/mnist/t10k-images-idx3-ubyte.gz to ./data/MNIST/MNIST/raw/t10k-images-idx3-ubyte.gz\n"
     ]
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "  0%|          | 0/1648877 [00:00<?, ?it/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Extracting ./data/MNIST/MNIST/raw/t10k-images-idx3-ubyte.gz to ./data/MNIST/MNIST/raw\n",
      "\n",
      "Downloading http://yann.lecun.com/exdb/mnist/t10k-labels-idx1-ubyte.gz\n",
      "Downloading http://yann.lecun.com/exdb/mnist/t10k-labels-idx1-ubyte.gz to ./data/MNIST/MNIST/raw/t10k-labels-idx1-ubyte.gz\n"
     ]
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "  0%|          | 0/4542 [00:00<?, ?it/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Extracting ./data/MNIST/MNIST/raw/t10k-labels-idx1-ubyte.gz to ./data/MNIST/MNIST/raw\n",
      "\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "Dataset MNIST\n",
       "    Number of datapoints: 60000\n",
       "    Root location: ./data/MNIST/\n",
       "    Split: Train"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "root_dir = './data/MNIST/'\n",
    "torchvision.datasets.MNIST(root=root_dir,download=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "XW1c2YmiHovW"
   },
   "source": [
    "MNIST datasets consists of small images of hand-written digits. The images are grayscale and have size 28 x 28. There are 60,000 training images and 10,000 testing images."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "p9MA5fqrHovZ"
   },
   "outputs": [],
   "source": [
    "train_set = torchvision.datasets.MNIST(root=root_dir, train=True, download=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "yaLXqwxaHovg"
   },
   "source": [
    "Define and initialize a data loader for the MNIST data already downloaded on disk."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "uEyTgg0THovj"
   },
   "outputs": [],
   "source": [
    "MNIST_dataset = torch.utils.data.DataLoader(train_set, batch_size=1, shuffle=True, num_workers=1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "f12CxE8XHovo"
   },
   "source": [
    "For the current notebook, we can format data as _numpy ndarrays_ which are easier to plot in matplotlib. The same operations can be easily performed on _pytorch Tensors_."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "_UnuFlpWHovq"
   },
   "outputs": [],
   "source": [
    "images = train_set.data.numpy().astype(np.float32)/255\n",
    "labels = train_set.targets.numpy()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "RpkGWiaqHovz"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(60000, 28, 28) (60000,)\n"
     ]
    }
   ],
   "source": [
    "print(images.shape,labels.shape)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "tPtQoS_-HowJ"
   },
   "source": [
    "## 2. Data visualization\n",
    "\n",
    "For convenience we define a few functions for formatting and plotting our image data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "F3lsBB7ZHowK"
   },
   "outputs": [],
   "source": [
    "# plot multiple images\n",
    "def plots(ims, interp=False, titles=None):\n",
    "    ims=np.array(ims)\n",
    "    mn,mx=ims.min(),ims.max()\n",
    "    f = plt.figure(figsize=(12,24))\n",
    "    for i in range(len(ims)):\n",
    "        sp=f.add_subplot(1, len(ims), i+1)\n",
    "        if not titles is None: sp.set_title(titles[i], fontsize=18)\n",
    "        plt.imshow(ims[i], interpolation=None if interp else 'none', vmin=mn,vmax=mx)\n",
    "\n",
    "# plot a single image\n",
    "def plot(im, interp=False):\n",
    "    f = plt.figure(figsize=(3,6), frameon=True)\n",
    "    plt.imshow(im, interpolation=None if interp else 'none')\n",
    "\n",
    "plt.gray()\n",
    "plt.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "vfxlah5eHowW"
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAARcAAAEVCAYAAADKG6HfAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/P9b71AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAU1ElEQVR4nO3dcWzUd/3H8dcV6MG29mqB9nqhQGEKZGwsEsCGhTCpFEzI2DBuqBGMGQGPxUIMpgljMpecYuZwrsIfOrolMhQjICSiUKANgWKokA6nDRAcneW6getdKVCa9vP7Y9n9vFG+X47eh/teeT6ST7L7vj/3/b73pX3l2+/3e9/zGWOMACDNcjLdAIDBiXABYAXhAsAKwgWAFYQLACsIFwBWEC4ArCBcAFhBuACwYmimG/isvr4+tbW1KS8vTz6fL9PtAPgMY4w6OzsVCoWUk+NwfGIseeONN8y4ceOM3+83M2fONCdOnLij97W2thpJDAbD46O1tdXxd9lKuOzYscPk5uaaN9980/zjH/8wzz//vCkoKDDt7e2u7+3o6Mj4TmMwGO6jo6PD8XfZSrjMnDnThMPhxOve3l4TCoVMJBJxfW8sFsv4TmMwGO4jFos5/i6n/YTuzZs31dTUpIqKisSynJwcVVRU6Pjx47fM7+7uVjweTxoAsl/aw+Xy5cvq7e1VcXFx0vLi4mJFo9Fb5kciEQUCgcQoLS1Nd0sAMiDjl6Krq6sVi8USo7W1NdMtAUiDtF+KHjVqlIYMGaL29vak5e3t7QoGg7fM9/v98vv96W4DQIal/cglNzdX06dPV11dXWJZX1+f6urqVF5enu7NAfCqAV8a6seOHTuM3+83tbW15r333jMrVqwwBQUFJhqNur6Xq0UMRnYMt6tFVu7QffbZZ/XRRx9pw4YNikajevzxx7V///5bTvICGLx8xnjrAd3xeF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OXmzZtqampSRUVFYllOTo4qKip0/PjxDHaW3S5cuKBoNJq0XwOBgGbNmsV+vQOxWEySVFhYKElqampST09P0v6cPHmyxo4de9/vT8+Gy+XLl9Xb26vi4uKk5cXFxYpGoxnqKvt9uu/Yr6nr6+tTVVWVZs+eralTp0r6ZH/m5uaqoKAgaS7704OPXAC8KhwO68yZMzp69GimW8kKnj1yGTVqlIYMGXLLWff29nYFg8EMdZX9Pt137NfUrF69Wvv27dPhw4eTnjcUDAZ18+ZNdXR0JM1nf3o4XHJzczV9+nTV1dUllvX19amurk7l5eUZ7Cy7lZWVKRgMJu3XeDyuEydOsF/7YYzR6tWrtWvXLh06dEhlZWVJ9enTp2vYsGFJ+7OlpUUXL15kf2b6jLKTHTt2GL/fb2pra817771nVqxYYQoKCkw0Gs10a57W2dlpTp06ZU6dOmUkmZ///Ofm1KlT5v333zfGGPOTn/zEFBQUmD179pjm5mbz1FNPmbKyMnP9+vUMd+49q1atMoFAwBw5csRcunQpMa5du5aYs3LlSjN27Fhz6NAhc/LkSVNeXm7Ky8sz2LU3eDpcjDHml7/8pRk7dqzJzc01M2fONI2NjZluyfMOHz5sJN0yli1bZoz55HL0iy++aIqLi43f7zfz5s0zLS0tmW3ao/rbj5LMtm3bEnOuX79uvve975nPfe5z5oEHHjBPP/20uXTpUuaa9gie5wLACs+ecwGQ3QgXAFYQLgCsIFwAWEG4ALCCcAFgBeECwArCBYAVhAsAKwgXAFYQLgCs+D9FhaMePp6MYwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 300x600 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plot(images[5000])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "VY5890I1Howd"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "7"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "labels[5000]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "OEWipA5iHown"
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAA9EAAADnCAYAAAAZ+9VeAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/P9b71AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAoSklEQVR4nO3de3BU5f3H8U8CSUCERBASowRScYi1FmwkiiCFmpGhVg2itYj1VsFioAKW/ooXQESg4gWhURFBbB1EEQHFaitRQAViCThWQarDJamYaJBcgQDZ8/vDYW26z+rZZHfP7jnv18yZgQ8Pm+/B7+Py5SRPEizLsgQAAAAAAL5XotMFAAAAAAAQLxiiAQAAAACwiSEaAAAAAACbGKIBAAAAALCJIRoAAAAAAJsYogEAAAAAsIkhGgAAAAAAmxiiAQAAAACwiSEaAAAAAACbGKIBAAAAALCJITrOJSQk2L6GDBnidLlA2G3btk333XefrrjiCuXk5KhLly5KSkpSly5dNGDAAD3wwAP6+uuvnS4TiKo5c+Y0+/8/4AW1tbX605/+pIsuukhdu3ZVSkqKzjjjDA0ZMkTTp09XdXW10yUCYXXo0CG9/vrrmjlzpq666ir16NHD///96dOnO12eq7V1ugC0Tnp6+nf++rFjx/wDRL9+/aJREhBVS5YsUVFRkf/n7dq1U/v27fX1119r06ZN2rRpk+bNm6dXXnlF/fv3d7BSIDp27dql++67z+kygKh6++23NXLkSFVWVkqSkpOTddJJJ+nzzz/X559/rvXr16ugoEB9+/Z1tlAgjN5//339/Oc/d7oMT+JJdJyrqKj4zuuuu+7yr/3Nb37jYKVAZOTl5Wnu3LnavHmzDh48qMOHD6u2tlZ1dXV69tln1bVrV1VVVamgoEA1NTVOlwtElM/n0y233KIjR47wj0bwjPfee0+XXXaZKisrddVVV+mf//ynjhw5ooMHD6qhoUHvv/++7r77bqWmpjpdKhB2p5xyii655BJNnjxZzz//vDIyMpwuyRMSLMuynC4CkfPDH/5QO3fu1MCBA/XOO+84XQ4Qdf/4xz80dOhQSdJzzz2nUaNGOVwREDmPPfaYJkyYoFGjRqlXr17+J9K81cOtDh06pHPPPVe7d+/W+PHjNX/+fKdLAqKmqalJbdq0aZb17NlT+/bt07Rp0/iU7gjiSbSLbdq0STt37pQk3XrrrQ5XAzjjwgsv9P/4P//5j4OVAJG1Z88e3X333erSpYseffRRp8sBouKvf/2rdu/erYyMDD344INOlwNE1f8O0IgevibaxRYvXixJSk1N1TXXXONwNYAz/vszMM4880wHKwEia/To0WpoaNDjjz+url27Ol0OEBV/+ctfJEnXXHON2rVr53A1ALyCJ9EuVV9frxdffFGSNHLkSJ100kkOVwRET2Njo/bu3as///nP+vWvfy1J6tWrly6//HKHKwMiY9GiRSouLlZ+fr5uuOEGp8sBoqKxsVFbt26VJOXm5qqsrExjxoxR9+7dlZycrPT0dF1++eV67bXXHK4UgNvwJNqlli9frvr6ekl8Kje8o127dmpsbAzIBwwYoGXLliklJcWBqoDI+vzzzzV58mS1b99eCxcudLocIGr27t2ro0ePSpL/a6Lr6uqUnJysDh066Msvv9TatWu1du1a3XrrrXrqqaf4lm8AwoIn0S719NNPS5L69Omj3Nxch6sBoiMjI0Pp6enq0KGDPxsyZIjmzZunrKwsBysDIue2225TTU2Npk+frh/84AdOlwNEzcGDB/0/njlzppKSkrRixQrV19fr4MGD2rdvn//L2Z5++mnOCgAQNgzRLvTxxx+rpKREEk+h4S179+5VRUWF6uvrVVlZqYceekgffPCB8vLyNHXqVKfLA8Luueee02uvvaa+fftq0qRJTpcDRJXP52v248WLF+vqq69WUlKSJCkrK0vLly9Xnz59JEmzZs3S8ePHHakVgLswRLvQiafQ7dq10/XXX+9wNYAzunXrpjvvvFNvvPGGEhISdP/992vt2rVOlwWETWVlpSZMmKA2bdpo0aJFatuWr9CCt3Ts2NH/47POOksFBQUBaxITE/X73/9eknTgwAGV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r/S+7aA/R/63ltD7ip/yX2QGvR//L/PB7vl/5vHa/1v8QeiNf7jMkhOjk5Wbm5uSouLvZnPp9PxcXF6t+/v4OVRUZ2drYyMjKa3W9tba1KSkri6n4ty9K4ceO0atUqvfXWW8rOzm7267m5uUpKSmp2n7t27VJZWVlc3Wekea3/JXfsAfo/fLy2B9zQ/xJ7IFzof/rfy7zW/xJ7IG73gKPHmn2H5cuXWykpKdbSpUutHTt2WGPGjLHS0tKsiooKp0trkbq6Omv79u3W9u3bLUnWI488Ym3fvt3at2+fZVmWNWfOHCstLc1as2aN9eGHH1pXXnmllZ2dbR0+fNjhyu0bO3aslZqaaq1fv9764osv/NehQ4f8a377299aWVlZ1ltvvWVt3brV6t+/v9W/f38Hq45Nbut/y3L/HqD/w8tte8Dt/W9Z7IFwov/pfy9zW/9bFnvgBDftgZgdoi3LshYsWGBlZWVZycnJVl5enrVlyxanS2qxt99+25IUcN14442WZX1zvP29995rpaenWykpKdYll1xi7dq1y9miQ2S6P0nWM888419z+PBh6/bbb7dOOeUU66STTrKGDx9uffHFF84VHcPc1P+W5f49QP+Hn5v2gNv737LYA+FG/9P/Xuam/rcs9sAJbtoDCZZlWeF5pg0AAAAAgLvF5NdEAwAAAAAQixiiAQAAAACwiSEaAAAAAACbGKIBAAAAALCJIRoAAAAAAJsYogEAAAAAsIkhGgAAAAAAmxiiAQAAAACwiSEaAAAAAACbGKIBAAAAALCJIRoAAAAAAJsYogEAAAAAsOn/AeBYWPfNsAZXAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 1200x2400 with 5 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plots(images[5000:5005], titles=labels[5000:5005])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "jyc9VagHHo0S"
   },
   "source": [
    "## 3. A simple classifier\n",
    "\n",
    "In this section we will construct a basic binary classifier.\n",
    "Our classifier will tell us whether a given image depicts a _one_ or an _eight_. \n",
    "\n",
    "We fetch all images from the _eight_ class and from the _one_ class."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "ogJld-3qJDpW"
   },
   "outputs": [],
   "source": [
    "n=len(images)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "Itlgssc9Ho0U"
   },
   "outputs": [],
   "source": [
    "eights=[images[i] for i in range(n) if labels[i]==8]\n",
    "ones=[images[i] for i in range(n) if labels[i]==1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "RGY2P44IHo0X"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(5851, 6742)"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(eights), len(ones)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "CFmNNrKAHo0f"
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAA9EAAADOCAYAAAA5WIGgAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/P9b71AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAjQElEQVR4nO3deXRV1dnH8ScBchkMYZKECKmsOjB1wVq0YIpSlAiiIpOtVkC0CAUCXQxOIEPLi8YKCxCKoJZBa5WKGpBBKDKEZQVaItQigoqiqZAAQgYRCE32+4clSM9zcJ+bm9zhfD9rnT/yy+acfcKzudk55LlxxhgjAAAAAADge8WHewIAAAAAAEQLNtEAAAAAAFhiEw0AAAAAgCU20QAAAAAAWGITDQAAAACAJTbRAAAAAABYYhMNAAAAAIAlNtEAAAAAAFhiEw0AAAAAgCU20QAAAAAAWKpZV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y8vFw2bdok6enpYZxZ1WjZsqWkpKRcdL/FxcWyc+fOqLpfY4yMHj1asrOzZfPmzdKyZcuLPt+xY0epVavWRfd54MAB+eKLL6LqPqua3+pfJDbWAPUfOn5bA7FQ/yKsgVCh/ql/P/Nb/YuwBqJ2DYS1rdklLF++3AQCAbNs2TKzb98+M3z4cNOgQQOTn58f7qkFpaSkxOzevdvs3r3biIiZPXu22b17t/n888+NMcY8+eSTpkGDBmbVqlXm/fffN3369DEtW7Y0p0+fDvPM7Y0cOdIkJSWZrVu3miNHjlQc33zzTcWYESNGmLS0NLN582aza9cuk56ebtLT08M468gUa/VvTOyvAeo/tGJtDcR6/RvDGggl6p/697NYq39jWAPnxdIaiNhNtDHGzJ8/36SlpZmEhATTqVMns2PHjnBPKWhbtmwxIuI4hgwZYoz5tr39lClTTHJysgkEAqZ79+7mwIED4Z20R9r9iYhZunRpxZjTp0+bUaNGmYYNG5q6deuafv36mSNHjoRv0hEslurfmNhfA9R/6MXSGoj1+jeGNRBq1D/172exVP/GsAbOi6U1EGeMMaF5pg0AAAAAQGyLyN+JBgAAAAAgErGJBgAAAADAEptoAAAAAAAssYkGAAAAAMASm2gAAAAAACyxiQYAAAAAwBKbaAAAAAAALLGJBgAAAADAEptoAAAAAAAssYkGAAAAAMASm2gAAAAAACz9PxngwsCHpBepAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 1200x2400 with 5 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAA9EAAADOCAYAAAA5WIGgAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/P9b71AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAbQElEQVR4nO3dbWxW5fkA8KtVKL5AKzpbURDmzETdMGGiqDFu/ypq8GWamCVbotHMqcWJbpkz82VGHU4T3cSq0znIPiibcc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/+SdHiDP1D95lqX+K346NwAAANQKQzQAAABkZIgGAACAjAzRAAAAkJEhGgAAADIyRAMAAEBGhmgAAADIyBANAAAAGRmiAQAAICNDNAAAAGRkiAYAAICMDNEAAACQ0e6VTgAgi1//+tep8R/+8IcFsVdffTX12rlz56bGN27cWHpiAADkiifRAAAAkJEhGgAAADIyRAMAAEBGhmgAAADIyBANAAAAGTmdm6Jce+21qfEbb7wxNd7YmP59mpNOOqkgtnLlypLzon5MnTo1Nf69730vNd7f318Qmz59euq1hx12WGrc6dxUuzFjxqTGjzvuuILYL37xi9Rrjz/++LLmBCOhoaEhNf7www+nxk8//fSC2OGHH5567T//+c/SEwPimmuuSY3fcsstqfHbbrstNf7Tn/60bDlViifRAAAAkJEhGgAAADIyRAMAAEBGhmgAAADIyMFiDOmCCy4oiF199dWp16Yd7vS/JElSSkrkwPvvv58aX7VqVWr8zDPPHMl0oCo0NzenxlesWFEQ6+rqSr22ra0tNT7U9VAJe+yxR2p8qIPx9t5774LYqaeemnrtb3/729ITg5wZP358Qezyyy9PvXao/9fPnz8/Nf7mm28WxB588MHsyVUBT6IBAAAgI0M0AAAAZGSIBgAAgIwM0QAAAJCRIRoAAAAycjo3Qzr44IMLYuPGjatAJuTJ1q1bU+MbN24c5UygNg11CrfTuakFH330UWo87TTfiIgDDzywIPalL32prDlBPdt99/Rx8NJLLy2Itba2FrV3d3d3anz16tVF7VONPIkGAACAjAzRAAAAkJEhGgAAADIyRAMAAEBGhmgAAADIyOncRHt7e2r88ssvz7zHG2+8kRqfO3duanyo0/qgpaUlNT5jxozRTQRqVENDQ6VTgLLr7OxMjZ900kkFsenTp49wNlA/jj322NT4ggULhr33JZdckhpfv379sPeuNE+iAQAAICNDNAAAAGRkiAYAAICMDNEAAACQkSEaAAAAMnI6d46ccMIJqfFFixalxpubmzPvffvtt6fGN27cmHkPiIjYc889U+NTpkwZ9t5HH310anyo0+XVL7UoSZLU+Lhx40Y5EyifF154IfO15513Xmr86quvTo2/++67JeUEt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zJo1K1mzZk2lUyrZihUrkogoWOeff36SJP853v66665LWltbk6ampuT//u//kg0bNlQ26SKl3V9EJIsWLRq45uOPP04uu+yyZJ999kn23HPP5Nvf/nby7rvvVi7pKlZP9Z8k9d8D6r/86qkH6r3+k0QPlJv6V/95Vk/1nyR64DP11AMNSZIk5XmmDQAAAPWtKn8nGgAAAKqRIRoAAAAyMkQDAABARoZoAAAAyMgQDQAAABkZogEAACAjQzQAAABkZIgGAACAjAzRAAAAkJEhGgAAADIyRAMAAEBG/w8wAzd8fu1eAAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 1200x2400 with 5 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plots(eights[:5])\n",
    "plots(ones[:5])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "3Mxs-x1pHo0l"
   },
   "source": [
    "We keep the first 1000 digits for the test set and we average all the remaining digits."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "MEA8brOGHo0n"
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAARcAAAEVCAYAAADKG6HfAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/P9b71AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAYSElEQVR4nO3df0yU9x0H8PeBcIDA4YHceVYQdZtdnS4xyoidsZOILDG19Y+1WxabNDV1RxM1WxeS1a7dkttcsi3dmP1nkzWZZTOZmpqMxWGFNAMWmcZ0LkwoCgwOf/XuAOFA7rs/mt56FZ7Pg/d8vefo+5U8idzn4b5fHuTNw93n+T4OpZQCEZHFMlI9ASJamBguRKQFw4WItGC4EJEWDBci0oLhQkRaMFyISAuGCxFpwXAhIi0WpXoCnxaLxTA0NISCggI4HI5UT4eIPkUphd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deXKFbVv3z5VVFSkgsFgqqdma6Ojo+rixYvq4sWLCoD6+c9/ri5evKiuX7+ulFLqJz/5iSoqKlKnT59Wly9fVk8++aSqqKhQExMTKZ65/ezfv1+5XC51/vx5NTw8HN/u3r0b3+fFF19UZWVl6ty5c+rChQuqqqpKVVVVpXDW9mDrcFFKqV/96leqrKxMZWdnq82bN6uOjo5UT8n23n33XQXgvm3v3r1KqY/ejn7llVeUx+NRTqdTbd++XXV3d6d20jY123EEoI4dOxbfZ2JiQn3nO99RS5YsUXl5eeqpp55Sw8PDqZu0TXA9FyLSwravuRBRemO4EJEWDBci0oLhQkRaMFyISAuGCxFpwXAhIi0YLkSkBcOFiLRguBCRFgwXItLif98lSD9T6r8zAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 300x600 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "raws8 =  np.mean(eights[1000:],axis=0)\n",
    "\n",
    "plot(raws8)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "ipyVJA9OMUH-"
   },
   "source": [
    "We now do the same thing with the ones:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "Aa3a1Le2Ho07"
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAARcAAAEVCAYAAADKG6HfAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/P9b71AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAV1klEQVR4nO3db2xT1/3H8Y+TEvMvcRrSxHEbaPpnYxqDSQiyiA7RNSJkEyqUB2s1TVSqiuicSoC2SpFW2LpJ2Zi0Td0yugcbWbVRNh4AKg8ysVCCpiVMZCDUdYoApUs64lAosUkgf0jO70FV9+cS7rGJD7bD+yUdqfa58f1ySz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fWhsvly5c1MTGh8vLyhOfLy8sViUQyVFXu++TYcVxTNzk5qW3btmnVqlVasmSJpI+PZ0FBgYqLixO25Xhm4ZILQLYKh8N699139fe//z3TpeSErD1zKS0tVX5+/i1X3QcGBhQMBjNUVe775NhxXFPT0NCgI0eO6J133klYbygYDGpsbEyDg4MJ23M8szhcCgoKtHz5crW1tcWfm5ycVFtbm2pqajJYWW6rqqpSMBhMOK6xWEwnT57kuE7BGKOGhgYdPHhQx44dU1VVVcL88uXLNWvWrITj2d3drd7eXo5npq8oe9m/f7/x+/2mpaXFvPfee2bLli2muLjYRCKRTJeW1a5du2ZOnz5tTp8+bSSZn//85+b06dPmv//9rzHGmJ/85CemuLjYHD582Jw9e9Y8/fTTpqqqyty4cSPDlWefl156yQQCAXP8+HHT398fH9evX49vs3XrVrNw4UJz7Ngxc+rUKVNTU2NqamoyWHV2yOpwMcaYX/3qV2bhwoWmoKDArFy50nR2dma6pKz3zjvvGEm3jM2bNxtjPv44+tVXXzXl5eXG7/ebp556ynR3d2e26Cw11XGUZPbu3Rvf5saNG+Y73/mOuf/++83cuXPNxo0bTX9/f+aKzhKs5wLAiay95gIgtxEuAJwgXAA4QbgAcIJwAeAE4QLACcIFgBOECwAnCBcAThAuAJwgXAA48X9awypJQwiZTwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 300x600 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "raws1 =  np.mean(ones[1000:],axis=0)\n",
    "\n",
    "plot(raws1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "p6UJ-NicMUIA"
   },
   "source": [
    "We built a 'typical representative' of the eights and a 'typical representative' of the ones. Now for a new sample from the test set, we compute the distance between this sample and our two representatives and classify the sample with the label of the closest representative.\n",
    "\n",
    "For the distance between images, we just take the pixelwise squared distance."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "3ZML33QNHo1G"
   },
   "outputs": [],
   "source": [
    "# sum of squared distance\n",
    "def sse(a,b): return ((a-b)**2).sum()\n",
    "\n",
    "# return 1 if closest to 8 and 0 otherwise\n",
    "def is8_raw_n2(im): return 1 if sse(im,raws1) > sse(im,raws8) else 0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "IMqqBDrMMUID"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1000 1000\n"
     ]
    }
   ],
   "source": [
    "nb_8_predicted_8, nb_1_predicted_8 = [np.array([is8_raw_n2(im) for im in ims]).sum() for ims in [eights[:1000],ones[:1000]]]\n",
    "\n",
    "nb_8_predicted_1, nb_1_predicted_1 = [np.array([(1-is8_raw_n2(im)) for im in ims]).sum() for ims in [eights[:1000],ones[:1000]]]\n",
    "\n",
    "# just to check \n",
    "print(nb_8_predicted_1+nb_8_predicted_8, nb_1_predicted_1+nb_1_predicted_8)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "CFUntUqdHo1e"
   },
   "source": [
    "<img src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/2/26/Precisionrecall.svg/1024px-Precisionrecall.svg.png\" alt=\"Drawing\" style=\"width: 500px;\"/>\n",
    "\n",
    "source [wikipedia](https://en.wikipedia.org/wiki/Precision_and_recall)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "aaYe8malHo1f"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "precision 8: 0.9712460063897763 recall 8: 0.912\n",
      "precision 1: 0.9170593779453345 recall 1: 0.973\n",
      "accuracy : 0.9425\n"
     ]
    }
   ],
   "source": [
    "def compute_scores(nb_8_predicted_8,nb_8_predicted_1,nb_1_predicted_1,nb_1_predicted_8):\n",
    "    Precision_8 = nb_8_predicted_8/(nb_8_predicted_8+nb_1_predicted_8)\n",
    "    Recall_8 = nb_8_predicted_8/(nb_8_predicted_1+nb_8_predicted_8)\n",
    "    Precision_1 = nb_1_predicted_1/(nb_1_predicted_1+nb_8_predicted_1)\n",
    "    Recall_1 = nb_1_predicted_1/(nb_1_predicted_1+nb_1_predicted_8)\n",
    "    return Precision_8, Recall_8, Precision_1, Recall_1\n",
    "\n",
    "Precision_8, Recall_8, Precision_1, Recall_1 = compute_scores(nb_8_predicted_8,nb_8_predicted_1,nb_1_predicted_1,nb_1_predicted_8)\n",
    "\n",
    "print('precision 8:', Precision_8, 'recall 8:', Recall_8)\n",
    "print('precision 1:', Precision_1, 'recall 1:', Recall_1)\n",
    "print('accuracy :', (Recall_1+Recall_8)/2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "W7UtzI0uMUIH"
   },
   "source": [
    "This is our baseline for our binary classification task. Now your task will be to do better with convolutions!"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "unXh3clNHoyM"
   },
   "source": [
    "## 4. Filters and convolutions\n",
    "\n",
    "Let start with this visual explanation of [Interactive image kernels](http://setosa.io/ev/image-kernels/)\n",
    "\n",
    "In some fields, convolution or filtering can be better understood as _correlations_. \n",
    "In practice we slide the filter matrix over the image (a bigger matrix) always selecting patches from the image with the same size as the filter. We compute the dot product between the filter and the image patch and store the scalar response which reflects the degree of similarity/correlation between the filter and image patch.\n",
    "\n",
    "Here is a simple 3x3 filter, ie a 3x3 matrix (see [Sobel operator](https://en.wikipedia.org/wiki/Sobel_operator) for more examples)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "OWiIsQ38HoyP"
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAScAAAEZCAYAAADVKuOcAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZ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unJUuW6MEHH1RjY6PWrFmjVatW6fe//72fYwIwaKifd7548WItXry41/u3bNmiiRMn6sUXX5QkTZs2TYcPH9ZLL72kiooKv8YEYJCpa04NDQ0qLy/vcqyiokINDQ0pz+no6FA8Hu+yAAx+puIUjUaVm5vb5Vhubq7i8bj+9a9/dXtOJBJROBxOrsLCwoEYFYDPTMXpdlRXV8vzvORqaWlJ90gA+oGv15z6Ki8vT7FYrMuxWCymUCik4cOHd3tOMBhUMBgciPEADCBTr5zKyspUV1fX5di+fftUVlaWpokApIuvcbp27ZoaGxvV2Ngo6T9vFWhsbFRzc7Ok//xKtmLFiuT+J598Un//+9/13e9+V3/961/18ssv64033tBTTz3l55gALHI+OnDggJN006qsrHTOOVdZWekWLlx40zkzZ850mZmZbtKkSW7r1q19ekzP85wk53le/3wTAPpVb5+jAeecS2Mb+108Hlc4HJbneQqFQukeB8B/6e1z1NQ1JwD4BHECYBJxAmAScQJgEnECYBJxAmAScQJgEnECYBJxAmAScQJgEnECYBJxAmAScQJgEnECYBJxAmAScQJgEnECYBJxAmAScQJgEnECYBJxAmAScQJgEnECYBJxAmAScQJgEnECYBJxAmAScQJgkq9xqq+v19KlS1VQUKBAIKBdu3b1uP/gwYMKBAI3rWg06ueYAAzyNU5tbW0qKipSTU1Nn847e/asWltbkysnJ8enCQFYNdTPO1+8eLEWL17c5/NycnI0atSo/h8IwKDha5xu18yZM9XR0aEZM2bohz/8oebPn59yb0dHhzo6OpK34/G4JCkSiSgrK8v3WQH0TXt7e6/2mbognp+fry1btuitt97SW2+9pcLCQi1atEgnT55MeU4kElE4HE6uwsLCAZwYgF9MvXKaOnWqpk6dmrw9b948/e1vf9NLL72kX/3qV92eU11drbVr1yZvx+NxAgXcAUzFqTslJSU6fPhwyq8Hg0EFg8EBnAjAQDD1a113GhsblZ+fn+4xAAwwX185Xbt2TU1NTcnb586dU2Njo7KzszV+/HhVV1fr448/1i9/+UtJ0qZNmzRx4kRNnz5d7e3t+sUvfqH9+/frD3/4g59jAjDI1zgdP35cDz74YPL2J9eGKisrVVtbq9bWVjU3Nye/fv36dT399NP6+OOPNWLECN1///364x//2OU+APxvCDjnXLqH6E/xeFzhcFjr1q3jrQSAQe3t7Xr++efleZ5CoVDKfeavOQH430ScAJhEnACYRJwAmEScAJhEnACYRJwAmEScAJhEnACYRJwAmEScAJhEnACYRJwAmEScAJhEnACYRJwAmEScAJhEnACYRJwAmEScAJhEnACYRJwAmEScAJhEnACYRJwAmEScAJhEnACYRJwAmORrnCKRiObMmaORI0cqJydHy5Yt09mzZ2953ptvvql7771XWVlZuu+++/TOO+/4OSYAg3yN06FDh1RVVaUjR45o3759unHjhh566CG1tbWlPOe9997T8uXL9fjjj+vPf/6zli1bpmXLlun06dN+jgrAmIBzzg3Ug128eFE5OTk6dOiQFixY0O2eRx99VG1tbdqzZ0/y2Ny5czVz5kxt2bLllo8Rj8cVDoe1bt06ZWVl9dvsAPpHe3u7nn/+eXmep1AolHLfgF5z8jxPkpSdnZ1yT0NDg8rLy7scq6ioUENDQ7f7Ozo6FI/HuywAg9+AxSmRSGjNmjWaP3++ZsyYkXJfNBpVbm5ul2O5ubmKRqPd7o9EIgqHw8lVWFjYr3MDSI8Bi1NVVZVOnz6t7du39+v9VldXy/O85GppaenX+weQHkMH4kFWr16tPXv2qL6+XuPGjetxb15enmKxWJdjsVhMeXl53e4PBoMKBoP9NisAG3x95eSc0+rVq7Vz507t379fEydOvOU5ZWVlqqur63Js3759Kisr82tMAAb5+sqpqqpK27Zt0+7duzVy5MjkdaNwOKzhw4dLklasWKGxY8cqEolIkr797W9r4cKFevHFF7VkyRJt375dx48f16uvvurnqACM8fWV089//nN5nqdFixYpPz8/uXbs2JHc09zcrNbW1uTtefPmadu2bXr11VdVVFSk3/zmN9q1a1ePF9EB3Hl8feXUm7dQHTx48KZjjzzyiB555BEfJgIwWPC3dQBMIk4ATCJOAEwiTgBMIk4ATCJOAEwiTgBMIk4ATCJOAEwiTgBMIk4ATCJOAEwiTgBMIk4ATCJ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2rZsmXpHmVQuXjxonJycnTo0KEeP6bIIl45+ez69es6ceKEysvLk8cyMjJUXl6uhoaGNE6G/wWffL5ZdnZ2mifpO+Lks0uXLqmzs1O5ubldjufm5ib/nAfwQyKR0Jo1azR//nzNmDEj3eP02YB8KgGAgVdVVaXTp0/3+PlplhEnn40ePVpDhgxRLBbrcjwWi/X6o4iBvvo0H1NkBb/W+SwzM1PFxcWqq6tLHkskEqqrq1NZWVkaJ8OdqD8+psgKXjkNgLVr16qyslKzZ89WSUmJNm3apLa2Nq1cuTLdo5l27dq1Lh8yeO7cOTU2Nio7O1vjx49P42R29eZjigaNvvwPCnD7Nm/e7MaPH+8yMzNdSUmJO3LkSLpHMu/AgQPdfjB+ZWVlukczq7uflyS3devWdI/WZ7zPCYBJXHMCYBJxAmAScQJgEnECYBJxAmAScQJgEnECYBJxAmAScQJgEnECYBJxAmDS/wHjIuqEj/26BAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 300x600 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "top=[[-1,-1,-1],\n",
    "     [ 1, 1, 1],\n",
    "     [ 0, 0, 0]]\n",
    "\n",
    "plot(top)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "0dr63ciIMUIK"
   },
   "source": [
    "We now create a toy image, to understand how convolutions operate."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "jipouDFOHoyn"
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAARcAAAEVCAYAAADKG6HfAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/P9b71AAAACXBIWXMAAA9hAAAPYQGoP6dpAAATXElEQVR4nO3dcWiU9x3H8c/FJjetlyeNmrvcmri03SrM1YEzWX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Iyog0bNujIkSPTrj98+LDee+89HT16VD09PXryySfV3Nys0dHRBa40+Do6OpRIJNTd3a3z589rfHxc27Zt08jISLbP3r179eGHH+rUqVPq6OjQ7du39fLLL/tYdUAUfEfwBVRfX28SiUT28cTEhInH4yaZTPpYVXGRZNra2rKPJycnTSwWM2+//XZ22dDQkAmHw+bEiRM+VFhc7ty5YySZjo4OY8ynY1daWmpOnTqV7fPRRx8ZSaarq8uvMgMhsDOXhw8fqre3V01NTdllJSUlampqUldXl4+VFbebN28qnU7njKvjOGpoaGBc8/D5bTUqKyslSb29vRofH88Zz3Xr1qm2tnbJj2dgw+WTTz7RxMSEotFozvJoNKp0Ou1TVcXv87FjXAs3OTmpPXv2aPPmzVq/fr2kT8ezrKxMFRUVOX0ZzwBecgEIqkQioWvXrunPf/6z36UUhcDOXFavXq1ly5ZN2es+ODioWCzmU1XF7/OxY1wL09raqrNnz+rixYs51xuKxWJ6+PChhoaGcvozngEOl7KyMm3cuFHt7e3ZZZOTk2pvb1djY6OPlRW3uro6xWKxnHHNZDLq6elhXKdhjFFra6va2tp04cIF1dXV5azfuHGjSktLc8azr69Pt27dYjz93qM8k5MnT5pwOGzef/99849//MP85Cc/MRUVFSadTvtdWqANDw+by5cvm8uXLxtJ5p133jGXL182//rXv4wxxvz61782FRUV5syZM+bq1avme9/7nqmrqzMPHjzwufLgef31143jOObSpUtmYGAg2+7fv5/ts3v3blNbW2suXLhg/va3v5nGxkbT2NjoY9XBEOhwMcaY3/zmN6a2ttaUlZWZ+vp6093d7XdJgXfx4kUjaUrbtWuXMebTw9EHDhww0WjUhMNhs3XrVtPX1+dv0QE13ThKMseOHcv2efDggXnjjTfMU089ZVasWGF27NhhBgYG/Cs6ILieCwArArvPBUBxI1wAWEG4ALCCcAFgBeECwArCBYAVhAsAKwgXAFYQLgCsIFwAWEG4ALDivxim5Sie0xS+AAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 300x600 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "cross = np.zeros((28,28))\n",
    "cross += np.eye(28)\n",
    "for i in range(4):\n",
    "    cross[12+i,:] = np.ones(28)\n",
    "    cross[:,12+i] = np.ones(28)\n",
    "\n",
    "plot(cross)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "g0j7I3OKHoyt"
   },
   "source": [
    "Our `top` filter should highlight top horizontal border in the image."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "zXc6nlfYHoyx"
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAARcAAAEVCAYAAADKG6HfAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/P9b71AAAACXBIWXMAAA9hAAAPYQGoP6dpAAATQ0lEQVR4nO3df2xV9f3H8dct0lPUcruC7e2NLavuBxOEJQy6BkdwNJSaEKv9Y7plgcVIdLcm0CzOJorTLbmOJUrcOvhno5oMcSQDIiZdsMhtzNoudBCCbg2QblwCt06S3gtXemno5/uHX6+7Utre9ny459LnI/kk3HM+99x3PqSvfO45n3uOzxhjBAAuK8h1AQBuTYQLACsIFwBWEC4ArCBcAFhBuACwgnABYAXhAsAKwgWAFbfluoAvGx0d1fnz51VcXCyfz5frcgB8iTFGly5dUjAYVEHBOPMTY8nvfvc7s2DBAuM4jlmxYoXp7e2d1Pui0aiRRKPRPN6i0ei4f8tWZi5vv/22WlpatHPnTtXU1Gj79u2qr69Xf3+/ysrKxn1vcXGxJGnLli1yHMdGeQCmIZVK6bXXXkv/rd6IlXB59dVX9eSTT+onP/mJJGnnzp1699139cc//lHPPffcuO/9/KuQ4zgqKiqyUR4AF0x02sL1E7pXr15VX1+f6urqvviQggLV1dWpu7v7uv6pVEqJRCKjAch/rofLJ598omvXrqm8vDxje3l5uWKx2HX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dbUCgUDGuCYSCfX29jKuYzDGqLm5Wfv27dPhw4dVXV2dsX/ZsmWaPXt2xnj29/fr7NmzjGeuzyiPZ8+ePcZxHNPe3m4++ugjs2nTJlNSUmJisViuS/O0S5cumWPHjpljx44ZSebVV181x44dM//5z3+MMca88sorpqSkxBw4cMCcOHHCPPzww6a6utpcuXIlx5V7z9NPP238fr85cuSIuXDhQrp9+umn6T5PPfWUqaqqMocPHzZHjx41tbW1pra2NodVe4Onw8UYY37729+aqqoqU1hYaFasWGF6enpyXZLnvf/++0bSdW3Dhg3GmM8uR7/wwgumvLzcOI5j1qxZY/r7+3NbtEeNNY6SzK5du9J9rly5Yn7605+ar3zlK+b22283jzzyiLlw4ULuivYI7ucCwArPnnMBkN8IFwBWEC4ArCBcAFhBuACwgnABYAXhAsAKwgWAFYQLACsIFwBWEC4ArPg/9rNmUPfGBPMAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 300x600 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from scipy.ndimage import convolve, correlate\n",
    "\n",
    "corr_cross = correlate(cross,top)\n",
    "\n",
    "plot(corr_cross)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "5mi2j-hFHoy3"
   },
   "outputs": [],
   "source": [
    "?correlate"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "OdlQ_Kz8MUIS"
   },
   "source": [
    "What is done on the border of the image? \n",
    "\n",
    "## Padding\n",
    "\n",
    "![padding](https://dataflowr.github.io/notebooks/Module6/img/padding_conv.gif)\n",
    "\n",
    "source: [Convolution animations](https://github.com/vdumoulin/conv_arithmetic/blob/master/README.md)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "bPAEi-4gHoy-"
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0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PYn2efvppU1FRYY4fP25OnjxpampqTE1NTRqrzgwZHS7GGPOb3/zGVFRUmNzcXLN27VrT19eX7pIy3rvvvmsk3da2bdtmjPnscvQLL7xgSktLjdvtNhs3bjSDg4PpLTpDTXYcJZn9+/fH+nz66afmxz/+sfnSl75kFi1aZLZu3WquXr2avqIzBPdzAWBFxp5zAZDdCBcAVhAuAKwgXABYQbgAsIJwAWAF4QLACsIFgBWECwArCBcAVhAuAKz4P1KzhuRmNrU1AAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 300x600 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# to see the role of padding\n",
    "corr_cross = correlate(cross,top, mode='constant')\n",
    "plot(corr_cross)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "iSTy0Ka1HozC"
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAARcAAAEVCAYAAADKG6HfAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/P9b71AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAWSUlEQVR4nO3df0zU9x3H8dehcKLiISIcN9GibbWbP5o4ZcTO2ElElpja8sfa7Q9dmhq7o4mSpRtJa9duCZtLOtON6T+brMmsncnU1CYsFivOTFhFLTNzTC2tWH642nAo6sm47/5oet1V/H7v5D7e9/D5SL5JufeX7+ft1/riy/c+9/l6LMuyBABJlpHqBgCMTYQLACMIFwBGEC4AjCBcABhBuAAwgnABYAThAsAIwgWAEeNT3cCXRSIRdXd3KycnRx6PJ9XtAPgSy7J05coVBQIBZWTYXJ9YhvzmN7+xZs2aZXm9Xmvp0qVWa2trXN/X1dVlSWJjY3P51tXVZftv2ciVy5tvvqmamhrt2LFDpaWl2rZtmyoqKtTR0aGCggLb783JyZEkbdy4U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/enqKv09/m547wmprq6WgcOHNC7774bs96Q3+/XzZs31d/fH7M/59PF4ZKVlaXFixerqakp+lokElFTU5PKyspS2Fl6Kykpkd/vjzmvAwMDam1t5byOwLIsVVdXa+/evTp06JBKSkpi6osXL1ZmZmbM+ezo6NCFCxc4n6m+o2xn9+7dltfrtRoaGqx//vOf1oYNG6zc3Fyrt7c31a252pUrV6yTJ09aJ0+etCRZr776qnXy5Enro48+sizLsn7+859bubm51v79+6329nbrscces0pKSqzr16+nuHP3efbZZy2fz2cdPnzY6unpiW7Xrl2L7rNx40Zr5syZ1qFDh6zjx49bZWVlVllZWQq7dgdXh4tlWdavf/1ra+bMmVZWVpa1dOlSq6WlJdUtud67775rSbplW7dunWVZn70d/eKLL1qFhYWW1+u1Vq5caXV0dKS2aZca6TxKsnbu3Bnd5/r169YPfvADa+rUqdbEiROtxx9/3Orp6Uld0y7Bei4AjHDtPRcA6Y1wAWAE4QLACMIFgBGECwAjCBcARhAuAIwgXAAYQbgAMIJwAWAE4QLAiP8BoGbTmzqWqWMAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 300x600 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "corrtop = correlate(images[5000], top)\n",
    "plot(corrtop)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "6kp8ArumHozJ"
   },
   "source": [
    "By rotating the filter with 90 degrees and calling the ```convolve``` function we get the same response as with the previously called ```correlate``` function."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "K2m8hh6XHozL"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-1,  1,  0],\n",
       "       [-1,  1,  0],\n",
       "       [-1,  1,  0]])"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.rot90(top, 1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "MBratD5iHozV",
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAARcAAAEVCAYAAADKG6HfAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/P9b71AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAWSUlEQVR4nO3df0zU9x3H8dehcKLiISIcN9GibbWbP5o4ZcTO2ElElpja8sfa7Q9dmhq7o4mSpRtJa9duCZtLOtON6T+brMmsncnU1CYsFivOTFhFLTNzTC2tWH642nAo6sm47/5oet1V/H7v5D7e9/D5SL5JufeX7+ft1/riy/c+9/l6LMuyBABJlpHqBgCMTYQLACMIFwBGEC4AjCBcABhBuAAwgnABYAThAsAIwgWAEeNT3cCXRSIRdXd3KycnRx6PJ9XtAPgSy7J05coVBQIBZWTYXJ9YhvzmN7+xZs2aZXm9Xmvp0qVWa2trXN/X1dVlSWJjY3P51tXVZftv2ciVy5tvvqmamhrt2LFDpaWl2rZtmyoqKtTR0aGCggLb783JyZEkbdy4UV6v10R7AEYhHA5rx44d0X+rt2MkXF599VU988wz+v73vy9J2rFjh95++239/ve/149//GPb7/38VyGv10u4AC7mdNsi6Td0b968qba2NpWXl38xSEaGysvLdezYsVv2D4fDGhgYiNkApL+kh8snn3yi4eFhFRYWxrxeWFio3t7eW/avq6uTz+eLbsXFxcluCUAKpPyt6NraWoVCoejW1dWV6pYAJEHS77nk5+dr3Lhx6uvri3m9r69Pfr//lv25twKMTUm/csnKytLixYvV1NQUfS0SiaipqUllZWXJHg6ASxl5t6impkbr1q3T17/+dS1dulTbtm3T4OBg9N0jAGOfkXD5zne+o//85z/asmWLent79fDDD6uxsfGWm7wAxi5j0/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ZWVpa1dOlSq6WlJdUtud67775rSbplW7dunWVZn70d/eKLL1qFhYWW1+u1Vq5caXV0dKS2aZca6TxKsnbu3Bnd5/r169YPfvADa+rUqdbEiROtxx9/3Orp6Uld0y7Bei4AjHDtPRcA6Y1wAWAE4QLACMIFgBGECwAjCBcARhAuAIwgXAAYQbgAMIJwAWAE4QLAiP8BoGbTmzqWqWMAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 300x600 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "convtop = convolve(images[5000], np.rot90(top,2))\n",
    "plot(convtop)\n",
    "np.allclose(convtop, corrtop)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "XqFCxFXoHozd"
   },
   "source": [
    "Let's generate a few more variants of our simple 3x3 filter"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "A48nt8YqHoze"
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAA+EAAAD7CAYAAAAFHJWGAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/P9b71AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAeIUlEQVR4nO3dcWyU930/8M+RFDts2ClNsCGYhC1rSZoEKAHiZEuoaoXSLBrTVGXZJChKUrUyU1NHamHa4pFKM1ObLVJLS9OqZeuGknUtZGNtNgIFlGFGIUFrqhaJLgsowiZRGrt4w2H4fn/4F3tufMYmfr53z+X1kh4p99zz3H14yPse3j7fc4VisVgMAAAAIHNTyj0AAAAAvFMo4QAAAJCIEg4AAACJKOEAAACQiBIOAAAAiSjhAAAAkIgSDgAAAIko4QAAAJCIEg4AAACJKOEAAACQSGYl/LXXXos//MM/jLq6urj88svjvvvuizNnzoy5z/Lly6NQKIxYPvGJT2Q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ure size 1200x2400 with 4 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "straights=[np.rot90(top,i) for i in range(4)]\n",
    "plots(straights)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "cv5eeO7gHozn"
   },
   "source": [
    "We proceed similarly to generate a set of filters with a different behavior"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "xhJFADUoHozr"
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAA+EAAAD7CAYAAAAFHJWGAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/P9b71AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAefElEQVR4nO3df2zU930/8NeRFBs07JQm2BCchC1rSJoEKAHiZEqo6oXRLCrVVGVZJShKQjqZqZ4jbaHawppK86Y2K1JHCqhq2C+UrGshLeuyUWhAGc5oSNCaqkUiywKKsEmUxi4ecRi+7x98Y++KbWziz/vuc3k8pI+U+/jzuXvxIU+//eR8d4VisVgMAAAAIHOTyj0AAAAAvF8o4QAAAJCIEg4AAACJKOEAAACQiBIOAAAAiSjhAAAAkIgSDgAAAIko4QAAAJCIEg4AAACJKOEAAACQSGYl/M0334zPfOYzUVdXF5dccknce++9cfLkyVHPWbp0aRQKhZLtc5/7XFYjAmMgy1AdZBnyT46hOhSKxWIxiztevnx5HD9+PDZv3hynT5+O1atXx6JFi2Lbtm0jnrN06dL48Ic/HI888sjgvqlTp0ZdXV0WIwJjIMtQHWQZ8k+OoTpcnMWd/vSnP42nn346fvSjH8VNN90UERFf+9rX4hOf+ER85StfiVmzZo147tSpU6OxsTGLsYBxkmWoDrIM+SfHUD0yKeGdnZ1xySWXDH6DiIhoaWmJSZMmxX/8x3/Epz71qRHP/Yd/+If4+7//+2hsbIy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UejRHI8hBZHiLL+SPLQ2R5iCznixwPkeMhuc5xkQm1ePHiYmtr6+DtM2fOFGfNmlXs6Ogo41TlFxHF7du3l3uMinHixIliRBT37t1b7lEYgSwPT5ZLyXLlk+XhyXIpWa5scjw8OS6Vpxx7JnwCvfPOO3Hw4MFoaWkZ3Ddp0qRoaWmJzs7OMk5Gpenp6YmIiOnTp5d5EoYjy4yVLFc2WWasZLlyyTFjlaccK+ET6I033ogzZ85EQ0NDyf6Ghobo6uoq01RUmoGBgWhra4tbb701rr/++nKPwzBkmbGQ5cony4yFLFc2OWYs8pbji8s9ALzftLa2xksvvRTPPvtsuUcB3gNZhuogy5B/ecuxEj6BLr300rjooouiu7u7ZH93d3c0NjaWaSoqydq1a2Pnzp2xb9++mD17drnHYQSyzPnIcj7IMucjy5VPjjmfPObYr6NPoMmTJ8fChQtj9+7dg/sGBgZi9+7d0dzcXMbJKLdisRhr166N7du3x549e2LOnDnlHolRyDIjkeV8kWVGIsv5IceMJM859kz4BGtvb49Vq1bFTTfdFIsXL44NGzZEX19frF69utyjJXfy5Mk4cuTI4O1XXnklDh06FNOnT48rrriijJOl19raGtu2bYunnnoqpk2bNvgapvr6+pgyZUqZp2M4sjxElofIcv7I8hBZHiLL+SLHQ+R4SK5zXN43Z69OX/va14pXXHFFcfLkycXFixcXn3vuuXKPVBY//OEPixFxzrZq1apyj5bccNchIoqPP/54uUdjFLJ8liwPkeV8kuWzZHmILOePHJ8lx0PynONCsVgsZlPvAQAAgP/La8IBAAAgESUcAAAAElHCAQAAIBElHAAAABJRwgEAACARJRwAAAASUcIBAAAgESUcAAAAElHCAQAAIBElHAAAABJRwgEAACARJRwAAAAS+X/QaWMs+uy5wAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 1200x2400 with 4 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "br=[[ 0, 0, 1],\n",
    "    [ 0, 1,-1.5],\n",
    "    [ 1,-1.5, 0]]\n",
    "\n",
    "diags = [np.rot90(br,i) for i in range(4)]\n",
    "plots(diags)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "zhGJF9gNHoz0"
   },
   "source": [
    "We can compose filters to obtain more complex patterns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "k9ETAdFKHoz1"
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAA9EAAACSCAYAAABCFEksAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/P9b71AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAcYElEQVR4nO3df2xVZx3H8U/L+ouNlgGlXaUNJBIrkkiCg3UzCzNVsi1GcNFpjMMpLpPWhKExNNGNJSZFXTL8AdsfU3AmBNbEYRwLxpQfkwhbICERRpkm4GpYf83QskJ/SB//mD2ee7i9nHvvOfec89z3K7nJPfdebh/u5z7P7dPzPPdbYowxAgAAAAAAt1QadQMAAAAAAEgKJtEAAAAAAPjEJBoAAAAAAJ+YRAMAAAAA4BOTaAAAAAAAfGISDQAAAACAT0yiAQAAAADwiUk0AAAAAAA+MYkGAAAAAMAnJtEAAAAAAPgU2iR6586dWrx4sSorK7V69Wq99dZbYf0oFBC52ots7UW29iJbO5GrvcjWXmRbXEqMMSboJ92/f78ee+wxvfjii1q9erV27Nihrq4uXbhwQQsXLsz4b6empnT58mXNmTNHJSUlQTcNWTDG6OrVq2poaFBpaWleuUpkGydkay+ytZM3V4nPWlvQZ+1FtvYKMltyjY90n7WZHhy4VatWmba2Nuf4xo0bpqGhwXR2dt7y3/b29hpJXGJ06e3tzTtXso3nhWztvZCtnZfpXPPNllzjd6HP2nshW3svQWRLrvG7uD9rZ3KbAjYxMaHTp0+ro6PDua20tFStra06ceLETY8fHx/X+Pi4c2z+d2L8qaeeUkVF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lL09TUZMrLy82qVavMyZMno25SQUlKe9m9e7fzmOvXr5tNmzaZO++808yePdusX7/evPfee9E12odiz9UYsrWVrbkaQ7Zkay9bsy32XI0hW1vZmqsxZJu0bEv+12gAAAAAAHALsdsTDQAAAABAXDGJBgAAAADAJybRAAAAAAD4xCQaAAAAAACfmEQDAAAAAOATk2gAAAAAAHxiEg0AAAAAgE9MogEAAAAA8IlJNAAAAAAAPjGJBgAAAADAJybRAAAAAAD4xCQaAAAAAACf/gtdm3PSGOO1LwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 1200x2400 with 8 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "rots = straights + diags\n",
    "corrs_cross = [correlate(cross, rot) for rot in rots]\n",
    "plots(corrs_cross)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "5GnSnG1HHoz5"
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAA9EAAACSCAYAAABCFEksAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/P9b71AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAtC0lEQVR4nO3dfWxV9f3A8U9RWpCHIiKtBSoVUQEVlCcL+DBXdDoX3dwyl82nuRk3WKIsWUKy+ZQluM1FswXnPxu6LT7EZLpMGOqKIm4gAkEBpTzIQxEogpQC0hbp+f3Br8fP99Pbw7m39/be8+37lTQ5t+fSnt7P/X7POdzP5/spCoIgEAAAAAAAcEq98n0AAAAAAAAkBTfRAAAAAADExE00AAAAAAAxcRMNAAAAAEBM3EQDAAAAABATN9EAAAAAAMTETTQAAAAAADFxEw0AAAAAQEzcRAMAAAAAEBM30QAAAAAAxJSzm+j58+fLyJEjpU+fPjJ16lRZuXJlrn4VuhFx9Rex9Rex9Rex9RNx9Rex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o0fL6NGjU+7LVVwtnZol4ralsGlIOm0yW+mwUe+RqDZINrVFp0/Z1Cr9O+z/Uur3nU1js+nJ6chXbC+//PJw26bA6jRKW+qg0+Gj0rntuNGv34YNG5x9ccetTROyKU16bNoxrt8He/fu7fR32GOJSiM+lXzFVqfv6ve7iNvSwo7NbKQ7R6WS2bEZlfZrL270Jwv2fafLEexY1OcPew7KVL7iql/bu+66y9mnx4YdF3HPtbaNlZ7n7LjQZQFRbMmMHZf6uNeuXevs0+ms9vXWcbXHfeDAgVjHlkq+Yrt8+fJw2865mr3m0GPKppRqNtVbtyiysY3b5s+27rGp3xdddFG4becWPfdce+21zr7XX3893M7mTU6+YqvnJHsdpbNFbVlcpincerzb95IusYxi3wP23Kvfd/Y6XF876WtpEfe62L4no0pETiUfsdXz04UXXujs03OQbSOly9eixrql42rPs3Hjatnrm0mTJoXby5Ytc/bpMWtL6956661we+bMmc4++57vTlldWGzbtm2yd+9eqampCb9XWloqU6dOdSZwraWlRZqampwvFJbt27enHVcRYpsExNZfxNZPxNVfxNZfxNZfmcSWuPohqzfR7Z++lJWVOd8vKyvr9JOZefPmSWlpafhlP7FF/rUvyJNOXEWIbRIQW38RWz8RV38RW38RW39lElvi6oe8t7iaO3euHDp0KPyyq+EiuYitv4itv4itn4irv4itv4itn4irH7LaW6W8vFxETtax6BqNhoYGmTBhQsp/U1JScsp89jVr1oTbtiYmaol+3UbB1sppUa1yLr74YmefbcPRGZvPb9ur6FYb9rn674iqhbXHkmkbr1Npr39LJ64i8WKr2boX26okiWxrpXHjxoXbtlWWru2zNb1dqYmOksvY7tq1K9y273Fdf2pfB123lGnNVrbYNhv2f5o13WIlqrWZba2UK7mMrW5rpWsfk0zXe+oWXiJu3bet8dJjOls10VFyGdevfvWrne7TcbbrEcStcbW1xLp9UqZsLaUdo3odFdtSRV8/2LVR9NwTVY+YTbmMrb6WWbJkibNvxowZ4bZd40DXDKczH+vadBuTuLWptvb+k08+cR7/97//DbenT5/u7NPXWLamfezYseH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v1dSKuHRFbP/kSVxFiaxFbf/kSW+LaEbH1ky9xFSG2VlJiW3A30cXFxTJx4kSpra0Nv9fW1ia1tbVSXV2dxyPrXkEQyOzZs+Xll1+WJUuWSFVVlbN/4sSJ0rt3b+d1qqurk507dxbk60Rcv0Rs/eRbXEWIbTti6y/fYktcv0Rs/eRbXEWIbbvExbbblzKL4YUXXghKSkqCZ555Jvjwww+De++9Nxg0aFCwd+/efB9at/nJT34SlJaWBm+99VawZ8+e8Ovzzz8Pn3PfffcFlZWVwZIlS4JVq1YF1dXVQXV1dR6POhpxPYnY+snHuAYBsQ0CYuszH2NLXE8itn7yMa5BQGyDIHmxLcib6CAIgj/+8Y9BZWVlUFxcHEyZMiVYsWJFvg+pW4lIyq8FCxaEzzl27Fjw05/+NDjzzDODM844I/jmN78Z7NmzJ38HHUNPj2sQEFtf+RrXICC2xNZfvsa2p8c1CIitr3yNaxAQ26TFtuj/DxoAAAAAAJxCwdVEAwAAAABQqLiJBgAAAAAgJm6iAQAAAACIiZtoAAAAAABi4iYaAAAAAICYuIkGAAAAACAmbqIBAAAAAIiJm2gAAAAAAGLiJhoAAAAAgJi4iQYAAAAAICZuogEAAAAAiImbaAAAAAAAYvo/NvVMKHsN6aQAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 1200x2400 with 8 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "rots = straights + diags\n",
    "corrs = [correlate(images[5000], rot) for rot in rots]\n",
    "plots(corrs)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "plV6mfsjHoz-"
   },
   "source": [
    "Next we illustrate the effect of downsampling.\n",
    "We select the most basic downsampling technique: __max pooling__. We keep only the maximum value for sliding windows of size ```7x7```.\n",
    "__Max pooling__ is a handy technique with a few useful perks:\n",
    "- since it selects the maximum values it ensures invariance to translations\n",
    "- reducing the size is helpful since data becomes more compact and easier to compare\n",
    "- we will see later in this course that since max pooling reduces the size of our images, the operations performed later on in the network have bigger receptive field / concern a bigger patch in the input image and allow the discovery of higher level patterns."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "QfR3u9FYHo0E"
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAA8gAAACOCAYAAADtuyHuAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/P9b71AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAQp0lEQVR4nO3dX2iddx3H8U+TNtnENLWUdJZmtIpMSkFlrmMMpmCx6IX0Rr0Q1A06kFQo05vdOPAmeCMD3RwobUEYHQijsouiVLahbI5VFLs/VadISpdkrZJ2a0nbnMeLsc5u65ak53f+/PJ6QS6anX2f5znvPmf5LunpqqZpmgAAAMAKN9DtEwAAAIBeYEEGAACAWJABAAAgiQUZAAAAkliQAQAAIIkFGQAAAJJYkAEAACBJsrqTB2u1Wjl16lRGRkayatWqTh6ad2iaJufOncumTZsyMHD9/59E296hbb20rVc72+raO9yz9dK2XtrWaSldO7ognzp1KuPj4508JB9gamoqmzdvvu452vYebeulbb3a0VbX3uOerZe29dK2Tovp2tEFeWRkpJOHYxHa1aRTbbdu3Vp0/unTp4vOT5Jz584VP0bSf21ZvH5ru2bNmqLzR0dHi85POvPakLSnSS337IYNG4ofo5+6tnPOB7nllluKzj9z5kzR+Ym211L666ihoaGi85PkxIkTxY+RaPtO//rXv4rO75TF9OjoguzHCnpPu5p0qm07ftTl/dT0e7Tf2rJ4/da29HFKvy50Ujueq1ruWV3Lzfkgg4ODRedrW27OByn93Jf+vdNJ2tZpMT08kwAAABALMgAAACSxIAMAAEASCzIAAAAksSADAABAEgsyAAAAJFnmgvzQQw9ly5YtueGGG3L77bfnueeea/d50SXa1knXemlbL23rpGu9tK2XtivLkhfkxx57LPfdd18eeOCB/OlPf8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Z79+7N448/nt/97nfZunVrt0+p67StVw1tdX1v2taphq6Jtu9F23rV0FbXd6uha1JR2+69P9j7O3ToUDM8PNwcPHiwefHFF5t77723WbduXTM9Pd3tU1u073znO83o6Gjz5JNPNq+++uqVj/Pnz3f71LpK23r1e1tdr03bOvV716bR9lq0rVe/t9X1vfV716app23PLshN0zQ/+clPmptvvrkZGhpqduzY0Tz77LPdPqUlSfKeHwcOHOj2qXWdtvXq57a6vj9t69TPXZtG2/ejbb36ua2u19bPXZumnrarmqZp2v99aQAAAOgvPflnkAEAAKDTLMgAAAAQCzIAAAAksSADAABAEgsyAAAAJLEgAwAAQBILMgAAACSxIAMAAEASCzIAAAAksSADAABAEgsyAAAAJEn+ByY9G3YyfEl5AAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 1200x2400 with 8 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import skimage\n",
    "\n",
    "from skimage.measure import block_reduce\n",
    "\n",
    "def pool(im): return block_reduce(im, (7,7), np.max)\n",
    "\n",
    "plots([pool(im) for im in corrs])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "Ud1VbsiRHo1s"
   },
   "source": [
    "We now build a classifier with convolutions.\n",
    "\n",
    "To this end we select a set of training images depicting _eights_ and _ones_, we convolve them with our set of filters, pool them and average them for each class and filter. We will thus obtain a set of _representative_ signatures for _eights_ and for _ones_. \n",
    "Given a new test image we compute its features by convolution and pooling with the same filters and then compare them with the _representative_ features. The class with the most _similar_ features is chosen as prediction.\n",
    "\n",
    "\n",
    "We keep 1000 images of _eight_ for the test set and use the remaining ones for the training: we convolve them with our bank of filters, perform max pooling on the responses and store them in ```pool8```."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "ptgnsYPmHo1u"
   },
   "outputs": [],
   "source": [
    "pool8 = [np.array([pool(correlate(im, rot)) for im in eights[1000:]]) for rot in rots]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "UoxKz3LNHo10"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(8, (4851, 4, 4))"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(pool8), pool8[0].shape"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "hUSDBnm9Ho13"
   },
   "source": [
    "We plot the result of the first filter+pooling on the first 5 _eights_ in our set. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "zlqkFm1RHo14"
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAA8gAAADMCAYAAACvK4qJAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/P9b71AAAACXBIWXMAAA9hAAAPYQGoP6dpAAASN0lEQVR4nO3dX2idd/0H8HfT0tOWJdE6+o+mbCCIc6xC15YyKJvUlQrDoYJ3K0UEJS2MXhkEeyEjIiiVWqoXus2LYt1FHQzcGNW1iqtzHUWnOP+gEOnariBpjZB2zfnd5bduzUlPcpLnPOf7esG5SDjp8+HJ+9PnvHNyTpY0m81mAAAAoHB9VQ8AAAAA3UBBBgAAgCjIAAAAkERBBgAAgCQKMgAAACRRkAEAACCJggwAAABJFGQAAABIkixb7ANOTU3lwoUL6e/vz5IlSxb78BSu2Wzm2rVr2bBhQ/r6Fv/nQ/JPleSf0tkBSib/lO5Od2DRC/KFCxcyNDS02IeFW4yNjWXjxo2Lflz5pxvIP6WzA5RM/indbDuw6AW5v79/sQ/Ztg996ENVj9DSP/7xj6pHmNUXvvCFqke4rXfffTe//vWvK8thHfL/9NNPVz1CS5/73OeqHmFWg4ODVY/QkvzP7Ot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wAAABJFGQAAABIoiADAABAEgUZAAAAkijIAAAAkERBBgAAgCRtFuRjx47lgQceyMDAQAYGBrJjx4784he/WKjZoOvYAUom/5RM/imdHaAUbRXkjRs35lvf+lbOnTuX119/PZ/61Kfy2c9+Nn/6058Waj7oKnaAksk/JZN/SmcHKMWydu782GOP3fLxU089lWPHjuXs2bP5xCc+0dHBoBvZAUom/5RM/imdHaAUbRXk97p582aee+65TExMZMeOHTPeb3JyMpOTk9MfX716da6HhK5yJzsg//Qq+adkHgNROtcAelnbb9L1xz/+MXfddVcajUa+8pWv5OTJk7nvvvtmvP/o6GgGBwenb0NDQ/MaGKrWzg7IP71G/imZx0CUzjWAErRdkD/2sY/l/Pnz+d3vfpevfvWr2bt3b/785z/PeP+RkZGMj49P38bGxuY1MFStnR2Qf3qN/FMyj4EonWsAJWj7V6yXL1+ej370o0mSLVu25Pe//32+973v5Yc//OFt799oNNJoNOY3JXSRdnZA/uk18k/JPAaidK4BlGDefwd5amrqltcXQGnsACWTf0om/5TODtCL2noGeWRkJHv27MmmTZty7dq1HD9+PK+88kpeeumlhZoPuoodoGTyT8nkn9LZAUrRVkG+fPlynnjiibz99tsZHBzMAw88kJdeeimf/vSnF2o+6Cp2gJLJPyWTf0pnByhFWwX5Rz/60ULNAbVgByiZ/FMy+ad0doBSzPs1yAAAANALFGQAAACIggwAAABJFGQAAABIoiADAABAEgUZAAAAkijIAAAAkERBBgAAgCQKMgAAACRRkAEAACCJggwAAABJFGQAAABIkixb7AM2m83FPmTbpqamqh6hpcnJyapHqL2qcliH/N+4caPqEVqamJioeoTak/+ZXbt2reoRWvrf//5X9Qg9wQ7U17vvvlv1CLUn/zPr9muADtAZs2VxSXOR0/rvf/87Q0NDi3lI+ICxsbFs3Lhx0Y8r/3QD+ad0doCSyT+lm20HFr0gT01N5cKFC+nv78+SJUvm/e9dvXo1Q0NDGRsby8DAQAcmLEtp56/ZbObatWvZsGFD+voW/xUG8t9dSjt/8s/7lXYO7QDvVdr5k3/eq8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TZs2NZcvX97ctm1b8+zZs1WPVAtJbnt7+umnqx6NNtmBubEDvUH+50b+e4P8z50d6A12YG7kf3a1/TvIAAAA0Em1fA0yAAAAdJqCDAAAAFGQAQAAIImCDAAAAEkUZAAAAEiiIAMAAEASBRkAAACSKMgAAACQREEGAACAJAoyAAAAJFGQAQAAIImCDAAAAEmS/wM4YE3Gib8nYwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 1200x2400 with 5 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plots(pool8[0][0:5])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "5i4oiuoeHo17"
   },
   "source": [
    "For the 4 first _eights_ in our set, we plot the result of the 8 filters+pooling"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "Av_HAmtJHo17"
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAA8gAAACOCAYAAADtuyHuAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/P9b71AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAQXUlEQVR4nO3dXWjddx3H8U+TLqlKmlpmu5VmrAhejMnEuY4yEIVo0asNBPFCZOAcI1XGLsSBuMvcDacOH8CuIEh3VSZlzknGFoSNQcfQOpgPUJquS7YqJGudSZrz92LYWddueTi/8/DL6wW5WIzf/+9/3pzTfpv0dEvTNE0AAABgkxvo9gEAAACgF1iQAQAAIBZkAAAASGJBBgAAgCQWZAAAAEhiQQYAAIAkFmQAAABIkmzt5MVarVbOnj2bkZGRbNmypZOX5v80TZO33nore/bsycDAxv+cRNveoW29tK1XO9vq2js8Z+ulbb20rdNaunZ0QT579mzGxsY6eUk+wMzMTPbu3bvhOdr2Hm3rpW292tFW197jOVsvbeulbZ1W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2R2djaf+tSn8tRTT73nL6/Tf7Stk6710rZe2tZJ13ppWy9tN58tTdM0nbrYwsJCRkdHi19n586dRef/4x//KDo/SQ4ePFh0/sWLF/PMM89kfn4+27dv3/C8TrX99Kc/XXT+m2++WXR+ko69WUO/tWX1tL3cd77zneLX+M1vflN0fqvVyunTp9vStpaug4ODxa/xpS99qej85eXl/O53v+u752zpx2XHjh1F5yfJk08+WXR+0zRZWFjou7all7r//eeQSvnb3/5WdP7Fixdz4sSJvmv7iU98ouj8U6dOFZ2fvPPPapW2mq5F38UaAAAA+oUFGQAAAGJBBgAAgCQWZAAAAEhiQQYAAIAk6/hnntphaGgoW7ZsKTb/kUceKTY7Saanp4vOT5K//OUvRee3Wq2i80v5yU9+UnT+K6+8UnR+knzzm98sfo0SSj9vf/GLXxSbnZR/B/Qk+f73v190/vLycvF3Zi3hV7/6VbePsGHz8/NF5y8tLeX06dNtnXnNNdcUfc7+/Oc/LzY7SUZGRorOT5IjR44Uv0YJpdved999xWYnydNPP110fpJ87WtfKzp/aWkphw8fbvvc4eHhom2/973vFZuddObX2rvuuqvo/FL/wE/ptt/97neLzU6SlZWVovOT5OGHHy42e2VlZdXvgO47yAAAABALMgAAACSxIAMAAEASCzIAAAAksSADAABAEgsyAAAAJLEgAwAAQBILMgAAACSxIAMAAEASCzIAAAAksSADAABAEgsyAAAAJLEgAwAAQBILMgAAACSxIAMAAEASCzIAAAAksSADAABAEgsyAAAAJLEgAwAAQBILMgAAACSxIAMAAEASCzIAAAAksSADAABAkmRrNy66tLRUdP7s7GzR+X/961+Lzk+SU6dOFb9GPxocHCw6f2DAnxldTenn7Z/+9Kei81966aWi85PkiSeeKH6NftQ0TdH5N910U9H5SfL1r3+9+DXabXl5uej8Y8eOFZ1/7733Fp2fJMePHy9+jRJKt3399deLzn/77beLzk+SX/7yl8WvUcLi4mLR+aV/LSz9ep8k//znP4tfo4TSbc+ePVt0funfpyXJq6++Wvwaq2EbAAAAgFiQAQAAIIkFGQAAAJJYkAEAACCJBRkAAACSWJABAAAgiQUZAAAAkliQAQAAIMkaF+TJycncdtttGRkZya5du3LnnXf2zD/ozMZoWydd66VtvbStl7Z10rVe2m5Oa1qQn3vuuUxMTOSFF17I73//+ywvL+eLX/xiLly4UOp8dIi2ddK1XtrWS9t6aVsnXeul7ea0dS1f/NRTT13230eOHMmuXbty4sSJfPazn23rwegsbeuka720rZe29dK2TrrWS9vNaU0L8v+bn59PkuzcufOK//vi4mIWFxcv/ffCwsJGLkcHaVunD+qaaNuvtK2X1+N6aVsnr8f10nZzWPebdLVardx///254447cvPNN1/xayYnJzM6OnrpY2xsbN0HpXO0rdNquiba9iNt6+X1uF7a1snrcb203TzWvSBPTEzk5MmTOXr06FW/5sEHH8z8/Pylj5mZmfVejg7Stk6r6Zpo24+0rZfX43ppWyevx/XSdvNY149YHzp0KMePH8/09HT27t171a8bHh7O8PDwug9H52lbp9V2TbTtN9rWy+txvbStk9fjemm7uaxpQW6aJt/+9rdz7NixPPvss9m3b1+pc9Fh2tZJ13ppWy9t66VtnXStl7ab05oW5ImJifz617/OE088kZGRkczOziZJRkdH86EPfajIAekMbeuka720rZe29dK2TrrWS9vNaU1/B/mnP/1p5ufn87nPfS7XX3/9pY/HH3+81PnoEG3rpGu9tK2XtvXStk661kvbzWnNP2JNnbStk6710rZe2tZL2zrpWi9tN6d1v4s1AAAA1MSCDAAAALEgAwAAQBILMgAAACSxIAMAAECSNb6Ldb/40Y9+VHT+V77ylaLzubpWq1V0/oULF4rO5+r27dtXdP6BAweKzk+SRx55pPg1+tH1119fdP6TTz5ZdD5Xtm3btqLz//jHPxadz9VNT08Xnf/JT36y6Hyu7vz580Xnv/baa0Xnc3VnzpwpOv8jH/lI0fm9xHeQAQAAIBZkAAAASGJBBgAAgCQWZAAAAEhiQQYAAIAkFmQAAABIYkEGAACAJBZkAAAASGJBBgAAgCQWZAAAAEhiQQYAAIAkFmQAAABIYkEGAACAJBZkAAAASGJBBgAAgCQWZAAAAEhiQQYAAIAkFmQAAABIYkEGAACAJBZkAAAASGJBBgAAgCQWZAAAAEhiQQYAAIAkydZOXqxpmo5cp9VqFZ2/uLhYdH4ntatJp9peuHCh6Py333676PxO6re2pR/78+fPF53fSf3WtvTz9t///nfR+Z3Ujiad6rq8vFx0vq7l5nwQbVdP28v5PXK5OR9kaWmpr+d3ymp6bGk6VS3JmTNnMjY21qnLsQozMzPZu3fvhudo23u0rZe29WpHW117j+dsvbStl7Z1Wk3Xji7IrVYrZ8+ezcjISLZs2bKq/8/CwkLGxsYyMzOT7du3Fz5hGb14D03T5K233sqePXsyMLDxn7TXtnfuodtte/ExWY9evA9tN65X76Gdbb0e9849eM62Ry/eh7bt0Yv3oe3G9eI9rKVrR3/EemBgYN1/ErN9+/aeeYDXq9fuYXR0tG2ztO2te+iFtr32mKxXr92Htu3Ri/fQrrZej3vrHjxn26fX7kPb9um1+9C2PXrtHlbb1Zt0AQAAQCzIAAAAkKQPFuTh4eE89NBDGR4e7vZR1q2Geyihhselhntot1oek1ruo51qeExquIcSanhcariHdqvlManlPtqplseklvtopxoek36/h46+SRcAAAD0qp7/DjIAAAB0ggUZAAAAYkEGAACAJBZkAAAASGJBBgAAgCQ9viA/+uijufHGG7Nt27bcfvvtefHFF7t9pDWZnJzMbbfdlpGRkezatSt33nlnXn311W4fqydoW69+bqvr+9O2Tv3cNdH2/Whbr35uq+vV9XPXpKK2TY86evRoMzQ01Bw+fLj585//3Nxzzz3Njh07mrm5uW4fbdUOHjzYPPbYY83Jkyebl19+ufnyl7/c3HDDDc358+e7fbSu0rZe/d5W16vTtk793rVptL0abevV7211vbJ+79o09bTt2QV5//79zcTExKX/XllZafbs2dNMTk528VQb88YbbzRJmueee67bR+kqbetVW1td36VtnWrr2jTa/pe29aqtra7vqK1r0/Rv2578EeulpaWcOHEi4+Pjlz43MDCQ8fHxPP/881082cbMz88nSXbu3Nnlk3SPtvWqsa2u79C2TjV2TbRNtK1ZjW11rbNr0r9te3JBPnfuXFZWVrJ79+7LPr979+7Mzs526VQb02q1cv/99+eOO+7IzTff3O3jdI229aqtra7v0rZOtXVNtP0vbetVW1td31Fb16S/227t9gE2i4mJiZw8eTJ/+MMfun0U2kzbOulaL23rpW29tK2TrvXq57Y9uSBfe+21GRwczNzc3GWfn5uby3XXXdelU63foUOHcvz48UxPT2fv3r3dPk5XaVuvmtrqejlt61RT10Tb/6VtvWpqq+u7auqa9H/bnvwR66Ghodx6662Zmpq69LlWq5WpqakcOHCgiydbm6ZpcujQoRw7dizPPPNM9u3b1+0jdZ229aqhra5Xpm2dauiaaHsl2tarhra6vlcNXZOK2nbv/cHe39GjR5vh4eHmyJEjzSuvvNJ861vfanbs2NHMzs52+2irdt999zWjo6PNs88+27z++uuXPv71r391+2hdpW29+r2trlenbZ36vWvTaHs12tar39vqemX93rVp6mnbswty0zTNj3/84+aGG25ohoaGmv379zcvvPBCt4+0Jkmu+PHYY491+2hdp229+rmtru9P2zr1c9em0fb9aFuvfm6r69X1c9emqaftlqZpmvZ/XxoAAAD6S0/+HWQAAADoNAsyAAAAxIIMAAAASSzIAAAAkMSCDAAAAEksyAAAAJDEggwAAABJLMgAAACQxIIMAAAASSzIAAAAkMSCDAAAAEmS/wB+mQgLiU1cxwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 1200x2400 with 8 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAA8gAAACOCAYAAADtuyHuAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/P9b71AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAQGklEQVR4nO3cX2iddx3H8U/SmNMV0sytNmtJxgqiIEPFbZ1zMLwoDrwa3ojOKQMnjEQYuxB2se1KAl7oYA69cd1upFOwTgoORt0fBhuDihedOBgIZtRkDjSpnW3X5PFirFtdU3PS8zvnPL+8XpCLZtn3eZ7z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ecn7X2NXLrt73//+6Lz77rrrqLzk+SnP/1p8WNshJ8gAwAAQCzIAAAAkMSCDAAAAEksyAAAAJDEggwAAABJLMgAAACQxIIMAAAASSzIAAAAkKTLBXl+fj433XRTJiYmsnv37txxxx15/fXXS50bfaRtnXStl7b10rZe2tZJ13ppuzV1tSC/8MILmZ2dzSuvvJJnn3027777br7yla/k1KlTpc6PPtG2TrrWS9t6aVsvbeuka7203ZrGuvniZ5555oI/P/HEE9m9e3eOHTuW2267racnRn9pWydd66VtvbStl7Z10rVe2m5NXS3I/2t5eTlJctVVV130v585cyZnzpw5/+eVlZXLORx9pG2d/l/XRNu20rZeno/rpW2dPB/XS9utYdNv0rW2tpb77rsvt956a66//vqLfs38/HwmJyfPf8zMzGz6ROkfbeu0ka6Jtm2kbb08H9dL2zp5Pq6XtlvHphfk2dnZHD9+PIcOHVr3ax544IEsLy+f/1hYWNjs4egjbeu0ka6Jtm2kbb08H9dL2zp5Pq6XtlvHpn7Fem5uLkeOHMmLL76Y6enpdb+u0+mk0+ls+uToP23rtNGuibZto229PB/XS9s6eT6ul7ZbS1cLctM0+f73v5/Dhw/n+eefz759+0qdF32mbZ10rZe29dK2XtrWSdd6abs1dbUgz87O5pe//GWefvrpTExMZHFxMUkyOTmZK664osgJ0h/a1knXemlbL23rpW2ddK2XtltTV/8G+Wc/+1mWl5fz5S9/OXv27Dn/8dRTT5U6P/pE2zrpWi9t66VtvbStk6710nZr6vpXrKmTtnXStV7a1kvbemlbJ13rpe3WtOl3sQYAAICaWJABAAAgFmQAAABIYkEGAACAJBZkAAAASNLlu1i3xdVXX110/re//e2i85PkySefLH6MNlpZWSk6f3TU94wG5Qtf+ELR+d/97neLzk+SH/7wh0XnN02TtbW1osco4V//+lfR+e7bwfjRj35UdP6dd95ZdH5S/h1q2/oOuHfddVfR+S+99FLR+Un554WmabK6ulr0GCX86le/Kjr/m9/8ZtH5SfK73/2u+DHaaN++fUXnHzx4sOj8JNm2bVux2d28hvKqAgAAAGJBBgA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bu3mZ+fH+BZXZ633nqrSdK88MILgz6VgdK2XrW11fUD2taptq5No+37tK1XbW11fU9tXZumvW2H8lesz549m2PHjuXAgQPnPzc6OpoDBw7k5ZdfHuCZXZ7l5eUkyVVXXTXgMxkcbetVY1td36NtnWrsmmibaFuzGtvqWmfXpL1th3JBfvvtt7O6upqpqakLPj81NZXFxcUBndXlWVtby3333Zdbb701119//aBPZ2C0rVdtbXX9gLZ1qq1rou37tK1XbW11fU9tXZN2tx0b9AlsFbOzszl+/HheeumlQZ8KPaZtnXStl7b10rZe2tZJ13q1ue1QLsi7du3Ktm3bsrS0dMHnl5aWcs011wzorDZvbm4uR44cyYsvvpjp6elBn85AaVuvmtrqeiFt61RT10TbD9O2XjW11fUDNXVN2t92KH/Fenx8PDfccEOOHj16/nNra2s5evRobrnllgGeWXeapsnc3FwOHz6cP/zhD9m3b9+gT2ngtK1XDW11vTht61RD10Tbi9G2XjW01fWjauiaVNR2cO8PdmmHDh1qOp1O88QTTzR//vOfm+9973vNlVde2SwuLg761Dbs3nvvbSYnJ5vnn3+++fvf/37+45133hn0qQ2UtvVqe1td16dtndretWm0XY+29Wp7W10vru1dm6aetkO7IDdN0zz66KPNtdde24yPjzf79+9vXnnllUGfUleSXPTj4MGDgz61gdO2Xm1uq+ulaVunNndtGm0vRdt6tbmtrutrc9emqaftSNM0Te9/Lg0AAADtMpT/BhkAAAD6zYIMAAAAsSADAABAEgsyAAAAJLEgAwAAQBILMgAAACSxIAMAAEASCzIAAAAksSADAABAEgsyAAAAJLEgAwAAQJLkv58nrkQKxlLuAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 1200x2400 with 8 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAA8gAAACOCAYAAADtuyHuAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9y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utbsmoxv25FckF977bVcvnw5e/bsuerze/bsydLS0pBOdX1WV1dz6NCh3H333bn99tuHfZyh0bauam11fYu2NVXrmmj7X9rWVa2trv9RrWsy3m23D/sAm8Xc3FxOnTqV3//+98M+Cn2mbU261qVtXdrWpW1NutY1zm1HckHetWtXtm3bluXl5as+v7y8nFtuuWVIp9q4+fn5PP3003n++eezb9++YR9nqLStq1JbXa+mbU2Vuiba/n/a1lWpra5vqdQ1Gf+2I/kj1hMTE7njjjty/PjxK59bXV3N8ePHc9dddw3xZL3pui7z8/N58skn89vf/ja33XbbsI80dNrWVaGtrtembU0VuibaXou2dVVoq+s7VeiaFGo7vPcHe3dHjx7tJicnu8cff7z785//3H3lK1/pbrrppm5paWnYR1u3r33ta9309HT37LPPdq+88sqVjwsXLgz7aEOlbV3j3lbXtWlb07h37Tpt16JtXePeVtdrG/euXVen7cguyF3XdY8++mi3f//+bmJiojtw4ED34osvDvtIPUlyzY8jR44M+2hDp21d49xW13enbU3j3LXrtH032tY1zm11Xds4d+26Om23dF3X9f/70gAAADBeRvLvIAMAAMCgWZABAAAgFmQAAABIYkEGAACAJBZkAAAASGJBBgAAgCQWZAAAAEhiQQYAAIAkFmQAAABIYkEGAACAJBZkAAAASJL8H6IXUuUmr9BNAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 1200x2400 with 8 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAA8gAAACOCAYAAADtuyHuAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/P9b71AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAPYklEQVR4nO3cXWjed/nH8U/TmazTNGOOditN2TySMR9gW8cYPhwUK8J0iCAelYETRjIoRYSJuJ3FA59QioLYDQVpT1aGYw5GZRuTjUlFsArzzGV0ydxJWrvRjub3PxDrv67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L27q0rUvb0XfVWr74+uuvz9atW7O4uHjZ5xcXF3PDDTe86+snJiYyMTGxsRPSF9rWtNauibajQtu6vB7X5Dlbl7Z1abs5reknyOPj47ntttty4sSJS59bXl7OiRMnctddd/X8cPSPtjXpWpe2dWlbk651aVuXtpvTmn6CnCSHDh3KgQMHcvvtt2fv3r358Y9/nHPnzuW+++5rcT76SNuadK1L27q0rUnXurStS9vNZ80L8le/+tX885//zHe/+90sLCzkk5/8ZJ5++ul3/eN1Ro+2Nelal7Z1aVuTrnVpW5e2m8+aF+QkmZ2dzezsbK/PwhDQtiZd69K2Lm1r0rUubevSdnNp+i7WAAAAMCosyAAAABALMgAAACSxIAMAAEASCzIAAAAkWee7WG/Unj17MjbWbjffunVrs9lJcuONNzadz8q+9a1vNZ3/7W9/u+n8JJmcnGx+jRampqayZcuWZvO/+MUvNpvdL0888cSgjzCUXn311abzt2/f3nT+qGr9nP3tb3/bbHaS/OpXv2o6f5S1/j7q9ttvbzY7SV544YWm80dZ67Z79uxpNjtJFhYWms4fZa3bPvDAA81mJ8nf//73pvOT5ODBg82vsRp+ggwAAACxIAMAAEASCzIAAAAksSADAABAEgsyAAAAJLEgAwAAQBILMgAAACSxIAMAAEASCzIAAAAksSADAABAEgsyAAAAJLEgAwAAQBILMgAAACSxIAMAAEASCzIAAAAksSADAABAEgsyAAAAJLEgAwAAQBILMgAAACSxIAMAAEASCzIAAAAksSADAABAEgsyAAAAJEmuGsRFX3311abz33777abzv/a1rzWdnyQ/+tGPml9jFP3iF79oOv+ee+5pOn+ULS0tNZ1/yy23NJ3/+OOPN53Pyr7+9a83nf+Tn/yk6fxR1fo5+73vfa/p/I9//ONN54+y1t9Hvf76603nf/nLX246P0l+/etfN79GC63bPvLII03nf+Yzn2k6f5S1brtt27am81t/nzZM/AQZAAAAYkEGAACAJBZkAAAASGJBBgAAgCQWZAAAAEhiQQYAAIAkFmQAAABIYkEGAACAJGtckOfm5nLHHXdkcnIyO3bsyL333ptXXnml1dnoI21r0rUubevSti5ta9K1Lm03pzUtyM8991xmZmby0ksv5Zlnnsk777yTz33uczl37lyr89En2taka13a1qVtXdrWpGtd2m5OV63li59++unL/vzYY49lx44dOXnyZD796U/39GD0l7Y16VqXtnVpW5e2Nelal7ab05oW5P+1tLSUJLnuuuuu+L+fP38+58+fv/TnM2fObORy9JG2Nb1f10TbUaVtXV6P69K2Jq/HdWm7Oaz7TbqWl5dz8ODB3H333bn11luv+DVzc3OZmpq69DE9Pb3ug9I/2ta0mq6JtqNI27q8HtelbU1ej+vSdvNY94I8MzOTU6dO5ejRoyt+zUMPPZSlpaVLH/Pz8+u9HH2kbU2r6ZpoO4q0rcvrcV3a1uT1uC5tN491/Yr17OxsnnzyyTz//PPZvXv3il83MTGRiYmJdR+O/tO2ptV2TbQdNdrW5fW4Lm1r8npcl7aby5oW5K7r8uCDD+b48eN59tlnc/PNN7c6F32mbU261qVtXdrWpW1Nutal7ea0pgV5ZmYmv/nNb/LEE09kcnIyCwsLSZKpqals27atyQHpD21r0rUubevSti5ta9K1Lm03pzX9G+Sf/exnWVpaymc/+9nceOONlz6OHTvW6nz0ibY16VqXtnVpW5e2Nelal7ab05p/xZqatK1J17q0rUvburStSde6tN2c1v0u1gAAAFCJBRkAAABiQQYAAIAkFmQAAABIYkEGAACAJGt8F+tRceDAgabzv/SlLzWdz8qOHDnSdP6nPvWppvNZ2Q9+8IOm85966qmm85Pk+PHjza8xin73u981nf/hD3+46Xyu7B//+EfT+ffcc0/T+azskUceaTr/8OHDTeezsg996ENN5//hD39oOp+VPfjgg03nf+c732k6f5j4CTIAAADEggwAAABJLMgAAACQxIIMAAAASSzIAAAAkMSCDAAAAEksyAAAAJDEggwAAABJLMgAAACQxIIMAAAASSzIAAAAkMSCDAAAAEksyAAAAJDEggwAAABJLMgAAACQxIIMAAAASSzIAAAAkMSCDAAAAEksyAAAAJDEggwAAABJLMgAAACQxIIMAAAASSzIAAAAkCS5qp8X67qun5dr5p133hn0EXqmV0361fbixYtN5587d67p/H7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5NSpU3nhhRcGfRR6TNuadK1L27q0rUvbmnSta5TbDuWCfP3112fr1q1ZXFy87POLi4u54YYbBnSq9Zudnc2TTz6Z559/Prt37x70cQZK27oqtdX1ctrWVKlrou3/p21dldrq+l+Vuiaj33Yof8V6fHw8t912W06cOHHpc8vLyzlx4kTuuuuuAZ5sbbquy+zsbI4fP57f//73ufnmmwd9pIHTtq4KbXW9Mm1rqtA10fZKtK2rQltd361C16RQ28G9P9h7O3r0aDcxMdE99thj3d/+9rfuG9/4Rnfttdd2CwsLgz7aqj3wwAPd1NRU9+yzz3avv/76pY+33npr0EcbKG3rGvW2uq5M25pGvWvXabsSbesa9ba6Xtmod+26Om2HdkHuuq776U9/2u3Zs6cbHx/v9u7d27300kuDPtKaJLnix6OPPjroow2ctnWNcltd35u2NY1y167T9r1oW9cot9V1ZaPctevqtN3SdV3X+59LAwAAwGgZyn+DDAAAAP1mQQYAAIBYkAEAACCJBRkAAACSWJABAAAgiQUZAAAAkliQAQAAIIkFGQAAAJJYkAEAACCJBRkAAACSWJABAAAgSfJ/pjNR6RcSc6cAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 1200x2400 with 8 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plots([pool8[i][0] for i in range(8)])\n",
    "plots([pool8[i][1] for i in range(8)])\n",
    "plots([pool8[i][2] for i in range(8)])\n",
    "plots([pool8[i][3] for i in range(8)])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "zqDZeWY6Ho1-"
   },
   "source": [
    "We normalize the data in order to smoothen activations and bring them to similar ranges of values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "D5wmCZY9Ho2A"
   },
   "outputs": [],
   "source": [
    "def normalize(arr): return (arr-arr.mean())/arr.std()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "5-bzBjC6Ho2D"
   },
   "source": [
    "Next we compute the average _eight_ by averaging all responses for each filter from _rots_."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "Ldr9Cpx5Ho2D"
   },
   "outputs": [],
   "source": [
    "filts8 = np.array([ims.mean(axis=0) for ims in pool8])\n",
    "filts8 = normalize(filts8)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "oZt78eGSHo2H"
   },
   "source": [
    "We should obtain a set of canonical _eights_ responses for each filter."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "_UdpsK6AHo2K"
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAA8gAAACOCAYAAADtuyHuAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/P9b71AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAQ/UlEQVR4nO3cX2jdd/3H8VeSNunq0mxdbWpJRifihVamzLXMgXhRHHjhhjfilZswYSTC2IWwG3uZGxFBhoK47UbtQBiFXhSk2tXJymh1Yjc3GYKm1KQbg6RNbdIm39/FWGfdsl+Tns/588njAUEas/f5fs+z32/yTtLT1zRNEwAAANjg+jt9AAAAANANLMgAAAAQCzIAAAAksSADAABAEgsyAAAAJLEgAwAAQBILMgAAACRJNrXzwVZWVnLu3LkMDw+nr6+vnQ/N/2iaJhcuXMju3bvT33/z3yfRtntoWy9t69XKtrp2D9dsvbStl7Z1WkvXti7I586dy/j4eDsfkv/H9PR0xsbGbnqOtt1H23ppW69WtNW1+7hm66VtvbSt0410beuCPDw8nCTp6+sr+h2UX/ziF8VmJ8k3vvGNovOT5MEHHyw6/+rVq3nxxRevNblZ7Wr7rW99q9jsJDl79mzR+Uly6tSpovObpsmlS5da3ra0z33u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GFTh9KR2lbr9ra6vo+betUW9em0fY92tartra6vqu2rk3Tu2278lesl5aWcvr06Rw4cODa+/r7+3PgwIG89NJLHTyymzM3N5ck2b59e4ePpHO0rVeNbXV9l7Z1qrFrom2ibc1qbKtrnV2T3m3blQvy22+/neXl5YyOjl73/tHR0czMzHToqG7OyspKHn/88dx///3Zu3dvpw+nY7StV21tdX2ftnWqrWui7Xu0rVdtbXV9V21dk95uu6nTB7BRTExM5MyZM3nxxRc7fSi0mLZ10rVe2tZL23ppWydd69XLbbtyQd6xY0cGBgYyOzt73ftnZ2eza9euDh3V+k1OTubIkSM5ceJExsbGOn04HaVtvWpqq+v1tK1TTV0Tbf+btvWqqa2u76upa9L7bbvyV6wHBwdzzz335NixY9fet7KykmPHjuW+++7r4JGtTdM0mZyczPPPP5/f/e53ueuuuzp9SB2nbb1qaKvrh9O2TjV0TbT9MNrWq4a2un5QDV2Titp27vXBPtqhQ4eaoaGh5tlnn21ee+215rvf/W5z2223NTMzM50+tBv22GOPNSMjI83x48ebf//739feLl261OlD6yht69XrbXVdnbZ16vWuTaPtarStV6+31fXD9XrXpqmnbdcuyE3TND/5yU+aO++8sxkcHGz27dvXnDx5stOHtCZJPvTtmWee6fShdZy29erltrp+NG3r1Mtdm0bbj6JtvXq5ra6r6+WuTVNP276maZrW/1waAAAAektX/htkAAAAaDcLMgAAAMSCDAAAAEksyAAAAJDEggwAAABJLMgAAACQxIIMAAAASSzIAAAAkMSCDAAAAEksyAAAAJDEggwAAABJkv8Dq7hlkiM6lcEAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 1200x2400 with 8 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plots(filts8)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "4HaAjI_uHo2O"
   },
   "source": [
    "We proceed similarly with training samples from the _one_ class and plot the canonical _ones_."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "e6baq8YKHo2P"
   },
   "outputs": [],
   "source": [
    "pool1 = [np.array([pool(correlate(im, rot)) for im in ones[1000:]]) for rot in rots]\n",
    "filts1 = np.array([ims.mean(axis=0) for ims in pool1])\n",
    "filts1 = normalize(filts1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "eq2CtFfAHo2T"
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAA8gAAACOCAYAAADtuyHuAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/P9b71AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAP5UlEQVR4nO3dUWjdZx3H4W+SLmndsowy2600YwMFkcKUbS1jKIrFgV64GxVBKLuYIokwdiEOwYE30RsVZOjV1qvRXc1BhYFUuiF0DCtedEK9EYl2STfY0rXb0pLzejHsrGtnkp73nPN/8zwQpDH+zvs/n5yT/Jr0OFZKKQEAAIAtbnzYBwAAAIBRYEEGAACAWJABAAAgiQUZAAAAkliQAQAAIIkFGQAAAJJYkAEAACBJsm2QN9br9XLmzJlMT09nbGxskDfN/yil5O23386ePXsyPn79f0+i7ejQtl3atqufbXUdHR6z7dK2Xdq2aSNdB7ognzlzJrOzs4O8Sf6PxcXF7N2797rnaDt6tG2Xtu3qR1tdR4/HbLu0bZe2bVpP14EuyNPT0wO5nc997nNV5//oRz+qOj9JDh06VHV+r9fL66+/3rcmg2r7xS9+ser8b33rW1XnJ8l3v/vdqvNLKUn612RQbScnJ6vO37lzZ9X5SfLWW29VnV9Kyerqaufa1r7vf/vb31adnyRf+9rXqs4vpeStt97qS5NBdd22re63EN/+9rerzk+S559/vur8fnZNBtd23759Ved/6Utfqjo/SQ4fPlx1fikl586d0/Z/fP3rX686P0l+8YtfVJ1fSsnKykrn2t59991V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6Fev5+fkcPXo0L730Uvbu3XvNj5uamsrU1NSmD8fgadum9XZNtO0abdvl+bhd2rbJ83G7tN1aNrQgl1Ly/e9/P88991yOHz+eu+66q9a5GDBt26Rru7Rtl7bt0rZNurZL261pQwvy3NxcnnnmmTz//POZnp7O0tJSkmRmZiY7duyockAGQ9s26doubdulbbu0bZOu7dJ2a9rQv0H+9a9/nZWVlXzhC1/I7bfffvnt2WefrXU+BkTbNunaLm3bpW27tG2Tru3Sdmva8K9Y0yZt26Rru7Rtl7bt0rZNurZL261p069iDQAAAC2xIAMAAEAsyAAAAJDEggwAAABJLMgAAACQZIOvYt0v4+PjGRsbqzb/X//6V7XZSfLmm29WnZ9091XzbrjhhqptT58+XW12kpw8ebLq/C678cYbq7b96U9/Wm12khw9erTq/CQ5fvx49dvoou3bt1edX/tzp6umpqaqPmY/9alPVZudJL/73e+qzk+6+7W21+tVbTs+XvfnJ//4xz+qzu+y2o/bV199tdrsJDl79mzV+Ul3H7cTExNV295www3VZifJxz/+8arzk1S9fzbyeeMnyAAAABALMgAAACSxIAMAAEASCzIAAAAksSADAABAEgsyAAAAJLEgAwAAQBILMgAAACSxIAMAAEASCzIAAAAksSADAABAEgsyAAAAJLEgAwAAQBILMgAAACSxIAMAAEASCzIAAAAksSADAABAEgsyAAAAJLEgAwAAQBILMgAAACSxIAMAAEASCzIAAAAksSADAABAkmTbIG+slHLFf9bS6/U6PX+Q+tViUG3Pnz9fdf7a2lrV+YPUtbYXLlyoOn91dbXq/KT+fdTv2xnUeWvf94N4Tu5S20E9Zt97772q8y9dulR1/iB17fm49tfCQbTt0mP2v+fUPnft5+NB3e+DoO2VWnncruc2xsoAP5P/+c9/ZnZ2dlA3xzosLi5m79691z1H29Gjbbu0bVc/2uo6ejxm26Vtu7Rt03q6DnRB7vV6OXPmTKanpzM2Nrau/825c+cyOzubxcXF3HzzzZVPWMcoXkMpJW+//Xb27NmT8fHr/017bUfnGobddhTvk80YxevQ9vqN6jX0s63n49G5Bo/Z/h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+fLj89a9/Ld/5znfKLbfcUpaWloZ9tHX73ve+V2ZmZsrx48fLa6+9dvntnXfeGfbRhkrbdnW9ra7Xpm2but61FG2vRdt2db2trlfX9a6ltNN2ZBfkUkr51a9+Ve64444yOTlZ9u/fX15++eVhH2lDklz17emnnx720YZO23Z1ua2uH03bNnW5aynafhRt29XltrpeW5e7ltJO27FSSun/z6UBAACgW0by3yADAADAoFmQAQAAIBZkAAAASGJBBgAAgCQWZAAAAEhiQQYAAIAkFmQAAABIYkEGAACAJBZkAAAASGJBBgAAgCQWZAAAAEiS/Bubz+hn+5DlaQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 1200x2400 with 8 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plots(filts1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "Bu97H3bNHo2Z"
   },
   "source": [
    "Do you notice any differences between ```filts8``` and ```filts1```? Which ones?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "Krvaio26Ho2a"
   },
   "source": [
    "We define a function that correlates a given image with all filters from ```rots``` and max pools the responses."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "kgnZzimPHo2a"
   },
   "outputs": [],
   "source": [
    "def pool_corr(im): return np.array([pool(correlate(im, rot)) for rot in rots])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "2vFjsSxcHo2c"
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAA8gAAACOCAYAAADtuyHuAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/P9b71AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAQXUlEQVR4nO3dXWjddx3H8U+TLqlKmlpmu5VmrAhejMnEuY4yEIVo0asNBPFCZOAcI1XGLsSBuMvcDacOH8CuIEh3VSZlzknGFoSNQcfQOpgPUJquS7YqJGudSZrz92LYWddueTi/8/DL6wW5WIzf/+9/3pzTfpv0dEvTNE0AAABgkxvo9gEAAACgF1iQAQAAIBZkAAAASGJBBgAAgCQWZAAAAEhiQQYAAIAkFmQAAABIkmzt5MVarVbOnj2bkZGRbNmypZOX5v80TZO33nore/bsycDAxv+cRNveoW29tK1XO9vq2js8Z+ulbb20rdNaunZ0QT579mzGxsY6eUk+wMzMTPbu3bvhOdr2Hm3rpW292tFW197jOVsvbeulbZ1W07WjC/LIyEhHrvPRj3606PxTp04VnZ8kd911V9H5Fy9ezPT0dNuadKrtLbfcUnT+uXPnis5Pktdee634NZL2NelUW1ZP28vde++9xa/x29/+tuj8VquVM2fOtKVJLV3b8Z2bD/KFL3yh6PyLFy9mamqq756z4+PjRefv2LGj6Pwkefrpp4vO/+93o/qt7cc+9rGi8z//+c8XnZ8kf//734vOX1lZycsvv9x3bT/+8Y8XnX/69Omi85NkeXm5+DVW06OjC3Knfqyg9HW2b99edH6SbN3amTTteqw61XZwcLDo/E78hqxT+q0tq6ft5YaHh4tfo1OvDe1oUkvXTtzHNddcU/waSf89Z0s/Lp143Pvt95ydOm/p17JOtPV75Csr/XvkzfRrSz3bAAAAAGyABRkAAABiQQYAAIAkFmQAAABIYkEGAACAJBZkAAAASLLOBfnRRx/NjTfemG3btuX222/Piy++2O5z0SXa1knXemlbL23rpGu9tK2XtpvLmhfkxx9/PA888EAeeuihvPTSS7nlllty8ODBvPHGGyXORwdpWydd66VtvbStk6710rZe2m4+a16QH3744dxzzz25++67c9NNN+VnP/tZPvzhD+fw4cMlzkcHaVsnXeulbb20rZOu9dK2XtpuPmtakJeWlnLixImMj4+/O2BgIOPj43n++eff8/WLi4tZWFi47IPepG2d1to10bZfaFsvr8d18pytl7b10nZzWtOCfO7cuaysrGT37t2XfX737t2Zn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ADAABAEgsyAAAAJLEgAwAAQBILMgAAACSxIAMAAEASCzIAAAAksSADAABAEgsyAAAAJLEgAwAAQBILMgAAACSxIAMAAEASCzIAAAAksSADAABAkmRrNy66tLRUdP7s7GzR+X/961+Lzk+SU6dOFb9GPxocHCw6f2DAnxldTenn7Z/+9Kei81966aWi85PkiSeeKH6NftQ0TdH5N910U9H5SfL1r3+9+DXabXl5uej8Y8eOFZ1/7733Fp2fJMePHy9+jRJKt3399deLzn/77beLzk+SX/7yl8WvUcLi4mLR+aV/LSz9ep8k//znP4tfo4TSbc+ePVt0funfpyXJq6++Wvwaq2EbAAAAgFiQAQAAIIkFGQAAAJJYkAEAACCJBRkAAACSWJABAAAgiQUZAAAAkliQAQAAIMkaF+TJycncdtttGRkZya5du3LnnXf2zD/ozMZoWydd66VtvbStl7Z10rVe2m5Oa1qQn3vuuUxMTOSFF17I73//+ywvL+eLX/xiLly4UOp8dIi2ddK1XtrWS9t6aVsnXeul7ea0dS1f/NRTT13230eOHMmuXbty4sSJfPazn23rwegsbeuka720rZe29dK2TrrWS9vNaU0L8v+bn59PkuzcufOK//vi4mIWFxcv/ffCwsJGLkcHaVunD+qaaNuvtK2X1+N6aVsnr8f10nZzWPebdLVardx///254447cvPNN1/xayYnJzM6OnrpY2xsbN0HpXO0rdNquiba9iNt6+X1uF7a1snrcb203TzWvSBPTEzk5MmTOXr06FW/5sEHH8z8/Pylj5mZmfVejg7Stk6r6Zpo24+0rZfX43ppWyevx/XSdvNY149YHzp0KMePH8/09HT27t171a8bHh7O8PDwug9H52lbp9V2TbTtN9rWy+txvbStk9fjemm7uaxpQW6aJt/+9rdz7NixPPvss9m3b1+pc9Fh2tZJ13ppWy9t66VtnXStl7ab05oW5ImJifz617/OE088kZGRkczOziZJRkdH86EPfajIAekMbeuka720rZe29dK2TrrWS9vNaU1/B/mnP/1p5ufn87nPfS7XX3/9pY/HH3+81PnoEG3rpGu9tK2XtvXStk661kvbzWnNP2JNnbStk6710rZe2tZL2zrpWi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3cNdH2/Whbr35uq+vV9XPXpKK2TY86evRoMzQ01Bw+fLj585//3Nxzzz3Njh07mrm5uW4fbdUOHjzYPPbYY83Jkyebl19+ufnyl7/c3HDDDc358+e7fbSu0rZe/d5W16vTtk793rVptL0abevV7211vbJ+79o09bTt2QV5//79zcTExKX/XllZafbs2dNMTk528VQb88YbbzRJmueee67bR+kqbetVW1td36VtnWrr2jTa/pe29aqtra7vqK1r0/Rv2578EeulpaWcOHEi4+Pjlz43MDCQ8fHxPP/881082cbMz88nSXbu3Nnlk3SPtvWqsa2u79C2TjV2TbRNtK1ZjW11rbNr0r9te3JBPnfuXFZWVrJ79+7LPr979+7Mzs526VQb02q1cv/99+eOO+7IzTff3O3jdI229aqtra7v0rZOtXVNtP0vbetVW1td31Fb16S/227t9gE2i4mJiZw8eTJ/+MMfun0U2kzbOulaL23rpW29tK2TrvXq57Y9uSBfe+21GRwczNzc3GWfn5uby3XXXdelU63foUOHcvz48UxPT2fv3r3dPk5XaVuvmtrqejlt61RT10Tb/6VtvWpqq+u7auqa9H/bnvwR66Ghodx6662Zmpq69LlWq5WpqakcOHCgiydbm6ZpcujQoRw7dizPPPNM9u3b1+0jdZ229aqhra5Xpm2dauiaaHsl2tarhra6vlcNXZOK2nbv/cHe39GjR5vh4eHmyJEjzSuvvNJ861vfanbs2NHMzs52+2irdt999zWjo6PNs88+27z++uuXPv71r391+2hdpW29+r2trlenbZ36vWvTaHs12tar39vqemX93rVp6mnbswty0zTNj3/84+aGG25ohoaGmv379zcvvPBCt4+0Jkmu+PHYY491+2hdp229+rmtru9P2zr1c9em0fb9aFuvfm6r69X1c9emqaftlqZpmvZ/XxoAAAD6S0/+HWQAAADoNAsyAAAAxIIMAAAASSzIAAAAkMSCDAAAAEksyAAAAJDEggwAAABJLMgAAACQxIIMAAAASSzIAAAAkMSCDAAAAEmS/wB+mQgLiU1cxwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 1200x2400 with 8 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plots(pool_corr(eights[1000]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "Td0bFQ04Ho2j"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAA8gAAACOCAYAAADtuyHuAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/P9b71AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAQXUlEQVR4nO3dXWjddx3H8U+TLqlKmlpmu5VmrAhejMnEuY4yEIVo0asNBPFCZOAcI1XGLsSBuMvcDacOH8CuIEh3VSZlzknGFoSNQcfQOpgPUJquS7YqJGudSZrz92LYWddueTi/8/DL6wW5WIzf/+9/3pzTfpv0dEvTNE0AAABgkxvo9gEAAACgF1iQAQAAIBZkAAAASGJBBgAAgCQWZAAAAEhiQQYAAIAkFmQAAABIkmzt5MVarVbOnj2bkZGRbNmypZOX5v80TZO33nore/bsycDAxv+cRNveoW29tK1XO9vq2js8Z+ulbb20rdNaunZ0QT579mzGxsY6eUk+wMzMTPbu3bvhOdr2Hm3rpW292tFW197jOVsvbeulbZ1W07WjC/LIyEhHrvPRj3606PxTp04VnZ8kd911V9H5Fy9ezPT0dNuadKrtLbfcUnT+uXPnis5Pktdee634NZL2NelUW1ZP28vde++9xa/x29/+tuj8VquVM2fOtKVJLV3b8Z2bD/KFL3yh6PyLFy9mamqq756z4+PjRefv2LGj6Pwkefrpp4vO/+93o/qt7cc+9rGi8z//+c8XnZ8kf//734vOX1lZycsvv9x3bT/+8Y8XnX/69Omi85NkeXm5+DVW06OjC3Knfqyg9HW2b99edH6SbN3amTTteqw61XZwcLDo/E78hqxT+q0tq6ft5Ya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oUFGQAAAGJBBgAAgCQWZAAAAEhiQQYAAIAk6/hnntphaGgoW7ZsKTb/kUceKTY7Saanp4vOT5K//OUvRee3Wq2i80v5yU9+UnT+K6+8UnR+knzzm98sfo0SSj9vf/GLXxSbnZR/B/Qk+f73v190/vLycvF3Zi3hV7/6VbePsGHz8/NF5y8tLeX06dNtnXnNNdcUfc7+/Oc/LzY7SUZGRorOT5IjR44Uv0YJpdved999xWYnydNPP110fpJ87WtfKzp/aWkphw8fbvvc4eHhom2/973vFZuddObX2rvuuqvo/FL/wE/ptt/97neLzU6SlZWVovOT5OGHHy42e2VlZdXvgO47yAAAABALMgAAACSxIAMAAEASCzIAAAAksSADAABAEgsyAAAAJLEgAwAAQBILMgAAACSxIAMAAEASCzIAAAAksSADAABAEgsyAAAAJLEgAwAAQBILMgAAACSxIAMAAEASCzIAAAAksSADAABAEgsyAAAAJLEgAwAAQBILMgAAACSxIAMAAEASCzIAAAAksSADAABAkmRrNy66tLRUdP7s7GzR+X/961+Lzk+SU6dOFb9GPxocHCw6f2DAnxldTenn7Z/+9Kei81966aWi85PkiSeeKH6NftQ0TdH5N910U9H5SfL1r3+9+DXabXl5uej8Y8eOFZ1/7733Fp2fJMePHy9+jRJKt3399deLzn/77beLzk+SX/7yl8WvUcLi4mLR+aV/LSz9ep8k//znP4tfo4TSbc+ePVt0funfpyXJq6++Wvwaq2EbAAAAgFiQAQAAIIkFGQAAAJJYkAEAACCJBRkAAACSWJABAAAgiQUZAAAAkliQAQAAIMkaF+TJycncdtttGRkZya5du3LnnXf2zD/ozMZoWydd66VtvbStl7Z10rVe2m5Oa1qQn3vuuUxMTOSFF17I73//+ywvL+eLX/xiLly4UOp8dIi2ddK1XtrWS9t6aVsnXeul7ea0dS1f/NRTT13230eOHMmuXbty4sSJfPazn23rwegsbeuka720rZe29dK2TrrWS9vNaU0L8v+bn59PkuzcufOK//vi4mIWFxcv/ffCwsJGLkcHaVunD+qaaNuvtK2X1+N6aVsnr8f10nZzWPebdLVardx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sqePXsyMLDxn7TXtnfuodtte/ExWY9evA9tN65X76Gdbb0e9849eM62Ry/eh7bt0Yv3oe3G9eI9rKVrR3/EemBgYN1/ErN9+/aeeYDXq9fuYXR0tG2ztO2te+iFtr32mKxXr92Htu3Ri/fQrrZej3vrHjxn26fX7kPb9um1+9C2PXrtHlbb1Zt0AQAAQCzIAAAAkKQPFuTh4eE89NBDGR4e7vZR1q2Geyihhselhntot1oek1ruo51qeExquIcSanhcariHdqvlManlPtqplseklvtopxoek36/h46+SRcAAAD0qp7/DjIAAAB0ggUZAAAAYkEGAACAJBZkAAAASGJBBgAAgCQ9viA/+uijufHGG7Nt27bcfvvtefHFF7t9pDWZnJzMbbfdlpGRkezatSt33nlnXn311W4fqydoW69+bqvr+9O2Tv3cNdH2/Whbr35uq+vV9XPXpKK2TY86evRoMzQ01Bw+fLj585//3Nxzzz3Njh07mrm5uW4fbdUOHjzYPPbYY83Jkyebl19+ufnyl7/c3HDDDc358+e7fbSu0rZe/d5W16vTtk793rVptL0abevV7211vbJ+79o09bTt2QV5//79zcTExKX/XllZafbs2dNMTk528VQb88YbbzRJmueee67bR+kqbetVW1td36VtnWrr2jTa/pe29aqtra7vqK1r0/Rv2578EeulpaWcOHEi4+Pjlz43MDCQ8fHxPP/881082cbMz88nSXbu3Nnlk3SPtvWqsa2u79C2TjV2TbRNtK1ZjW11rbNr0r9te3JBPnfuXFZWVrJ79+7LPr979+7Mzs526VQb02q1cv/99+eOO+7IzTff3O3jdI229aqtra7v0rZOtXVNtP0vbetVW1td31Fb16S/227t9gE2i4mJiZw8eTJ/+MMfun0U2kzbOulaL23rpW29tK2TrvXq57Y9uSBfe+21GRwczNzc3GWfn5uby3XXXdelU63foUOHcvz48UxPT2fv3r3dPk5XaVuvmtrqejlt61RT10Tb/6VtvWpqq+u7auqa9H/bnvwR66Ghodx6662Zmpq69LlWq5WpqakcOHCgiydbm6ZpcujQoRw7dizPPPNM9u3b1+0jdZ229aqhra5Xpm2dauiaaHsl2tarhra6vlcNXZOK2nbv/cHe39GjR5vh4eHmyJEjzSuvvNJ861vfanbs2NHMzs52+2irdt999zWjo6PNs88+27z++uuXPv71r391+2hdpW29+r2trlenbZ36vWvTaHs12tar39vqemX93rVp6mnbswty0zTNj3/84+aGG25ohoaGmv379zcvvPBCt4+0Jkmu+PHYY491+2hdp229+rmtru9P2zr1c9em0fb9aFuvfm6r69X1c9emqaftlqZpmvZ/XxoAAAD6S0/+HWQAAADoNAsyAAAAxIIMAAAASSzIAAAAkMSCDAAAAEksyAAAAJDEggwAAABJLMgAAACQxIIMAAAASSzIAAAAkMSCDAAAAEmS/wB+mQgLiU1cxwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 1200x2400 with 8 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#check \n",
    "plots([pool8[i][0] for i in range(8)])\n",
    "np.allclose(pool_corr(eights[1000]),[pool8[i][0] for i in range(8)])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "x2cJdyL2Ho2u"
   },
   "outputs": [],
   "source": [
    "# function used for a voting based classifier that will indicate which one of the \n",
    "# two classes is most likely given the sse distances\n",
    "# n2 comes from norm2\n",
    "# is8_n2 returns 1 if it thinks it's an eight and 0 otherwise\n",
    "def is8_n2(im): return 1 if sse(pool_corr(im),filts1) > sse(pool_corr(im),filts8) else 0"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "SDFMHV3nHo2y"
   },
   "source": [
    "We perform a check to see if our function actually works. We correlate the an image of _eight_ with ```filts8``` and ```filts1```. It should give smaller distance for the _eights_."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "C_eFq1EWHo2z"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(103.67323, 126.09805)"
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sse(pool_corr(eights[0]), filts8), sse(pool_corr(eights[0]), filts1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "yNINKzvKHo24"
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAARcAAAEVCAYAAADKG6HfAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/P9b71AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAVHklEQVR4nO3dcWzUd/3H8deV0YOxcrWU9jhpsRMnToQlBGrDIMA6oE5coSZuMYYtywjbMQPELVYHbKgp4jIcW2UmTsoyWRUNIGi6QBklxraGDiSTpQEs0EmvY2y9QrcW0n5+f/jz9KB8vz16H+6uPB/JJ+G+70+/3zff7V58eve973mMMUYAEGdpiW4AwNBEuACwgnABYAXhAsAKwgWAFYQLACsIFwBWEC4ArCBcAFhxW6IbuFpfX5/OnTunjIwMeTyeRLcD4CrGGF28eFGBQEBpaQ7rE2PJK6+8YiZMmGC8Xq+ZMWOGaWxsHNDPtba2GkkMBiPJR2trq+Nz2Uq4VFdXm/T0dPPrX//a/OMf/zCPP/64yczMNO3t7a4/29HRkfCTxmAw3EdHR4fjc9lKuMyYMcMEg8HI497eXhMIBExFRYXrz4bD4YSfNAaD4T7C4bDjcznuL+hevnxZTU1NKi4ujmxLS0tTcXGx6uvrr5nf09Ojzs7OqAEg9cU9XD788EP19vYqNzc3antubq5CodA18ysqKuTz+SIjLy8v3i0BSICEvxVdXl6ucDgcGa2trYluCUAcxP2t6OzsbA0bNkzt7e1R29vb2+X3+6+Z7/V65fV6490GgASL+8olPT1d06ZNU21tbWRbX1+famtrVVRUFO/DAUhWg35rqB/V1dXG6/Waqqoqc/z4cbNs2TKTmZlpQqGQ68/ybhGDkRrD7d0iK1fofutb39L58+e1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Xas2ePduzYobq6Op07d05LlixJYNdJIpYvor/ZZsyYYYLBYORxb2+vCQQCpqKiIoFdpRZJZufOnZHHfX19xu/3m5/97GeRbR0dHcbr9Zo333wzAR2mlg8++MBIMnV1dcaYf5+74cOHmx07dkTmvPfee0aSqa+vT1SbSSFpVy6XL19WU1OTiouLI9vS0tJUXFys+vr6BHaW2lpaWhQKhaLOq8/nU2FhIed1AMLhsCQpKytLktTU1KQrV65Enc9JkyYpPz//lj+fSRsuH374oXp7e5Wbmxu1PTc3V6FQKEFdpb7/nDvOa+z6+vq0cuVKzZw5U5MnT5b07/OZnp6uzMzMqLmczyS85QKQrILBoN5991395S9/SXQrKSFpVy7Z2dkaNmzYNa+6t7e3y+/3J6ir1Pefc8d5jc2KFSu0d+9evf3221H3G/L7/bp8+bI6Ojqi5nM+kzhc0tPTNW3aNNXW1ka29fX1qba2VkVFRQnsLLUVFBTI7/dHndfOzk41NjZyXvthjNGKFSu0c+dOHThwQAUFBVH1adOmafjw4VHns7m5WWfPnuV8JvoVZSfV1dXG6/Waqqoqc/z4cbNs2TKTmZlpQqFQoltLahcvXjRHjhwxR44cMZLMiy++aI4cOWLOnDljjDFmw4YNJjMz0+zevdscO3bMPPjgg6agoMB8+umnCe48+TzxxBPG5/OZgwcPmra2tsj45JNPInOWL19u8vPzzYEDB8zhw4dNUVGRKSoqSmDXySGpw8UYY15++WWTn59v0tPTzYwZM0xDQ0OiW0p6b7/9tpF0zVi6dKkx5t9vR69Zs8bk5uYar9dr7rvvPtPc3JzYppNUf+dRktm6dWtkzqeffmqefPJJ85nPfMbcfvvtZvHixaatrS1xTScJ7ucCwIqkfc0FQGojXABYQbgAsIJwAWAF4QLACsIFgBWECwArCBcAVhAuAKwgXABYQbgAsOL/AJ5T2N0HsBL0AAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 300x600 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plot(eights[0])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "roCmorVtHo29"
   },
   "source": [
    "We now test our classifier on the 1000 images of _eights_ and 1000 images of _ones_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "TEPN_aPbHo3K"
   },
   "outputs": [],
   "source": [
    "nb_8_predicted_8, nb_1_predicted_8 = [np.array([is8_n2(im) for im in ims]).sum() for ims in [eights[:1000],ones[:1000]]]\n",
    "\n",
    "nb_8_predicted_1, nb_1_predicted_1 = [np.array([(1-is8_n2(im)) for im in ims]).sum() for ims in [eights[:1000],ones[:1000]]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "FO4sLIjSHo3O"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "precision 8: 0.963220675944334 recall 8: 0.969\n",
      "precision 1: 0.9688128772635815 recall 1: 0.963\n",
      "accuracy : 0.966\n",
      "accuracy baseline: 0.9425\n"
     ]
    }
   ],
   "source": [
    "Precisionf_8, Recallf_8, Precisionf_1, Recallf_1 = compute_scores(nb_8_predicted_8,nb_8_predicted_1,nb_1_predicted_1,nb_1_predicted_8)\n",
    "\n",
    "print('precision 8:', Precisionf_8, 'recall 8:', Recallf_8)\n",
    "print('precision 1:', Precisionf_1, 'recall 1:', Recallf_1)\n",
    "print('accuracy :', (Recallf_1+Recallf_8)/2)\n",
    "print('accuracy baseline:', (Recall_1+Recall_8)/2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "yoy--n6IHo3b"
   },
   "source": [
    "We improved the accuracy while reducing the embedding size from a $28\\times 28 = 784$ vector to a $4\\times 4\\times 8 = 128$ vector.\n",
    "\n",
    "We have successfully built a classifier for _eights_ and _ones_ using features extracted with a bank of pre-defined features and a set of training samples. "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "collapsed": true,
    "id": "Y_mBZHv9Ho3d"
   },
   "source": [
    "## 5. Practicals: improving classification with Convolutional Neural Net\n",
    "\n",
    "You will now build a neural net that will learn the weights of the filters.\n",
    "\n",
    "The first layer of your network will be a convolutional layer with $8$ filters of size $3\\times 3$. Then you will apply a Max Pooling layer to reduce the size of the image to $4\\times 4$ as we did above. This will produce a (once flatten) a vector of size $128 = 4\\times 4\\times 8$. From this vector, you need to predict if the corresponding input is a $1$ or a $8$. So you are back to a classification problem as seen in previous lesson.\n",
    "\n",
    "You need to fill the code written below to construct your CNN. You will need to look for documentation about [torch.nn](https://pytorch.org/docs/stable/nn.html) in the Pytorch doc."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "F4ADp7YLHo3d"
   },
   "outputs": [],
   "source": [
    "import torch.nn as nn\n",
    "import torch.nn.functional as F\n",
    "\n",
    "class classifier(nn.Module):\n",
    "    \n",
    "    def __init__(self):\n",
    "        super(classifier, self).__init__()\n",
    "        # fill the missing entries below\n",
    "        self.conv1 = nn.Conv2d(in_channels=1, out_channels=8, kernel_size=3, padding=1)\n",
    "        self.fc = nn.Linear(in_features=128, out_features=2)\n",
    "        \n",
    "    def forward(self,x):\n",
    "        # implement your network here, use F.max_pool2d, F.log_softmax and do not forget to flatten your vector\n",
    "        x = self.conv1(x)\n",
    "        x = F.max_pool2d(x,7)\n",
    "        x = self.fc(torch.flatten(x,start_dim=1))\n",
    "        return F.log_softmax(x, dim=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "5YinNMu0Ho3g"
   },
   "outputs": [],
   "source": [
    "conv_class = classifier()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "EapjD0UQHo3k"
   },
   "source": [
    "Your code should work fine on a batch of 3 images."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "EtN49qaUHo3p"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "torch.Size([3, 2])"
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "batch_3images = train_set.data[0:2].type(torch.FloatTensor).resize_(3, 1, 28, 28)\n",
    "conv_class(batch_3images).shape"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "5s841xShHo3u"
   },
   "source": [
    "The following lines of code implement a data loader for the train set and the test set. No modification is needed."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "iO_mo1CaHo3u"
   },
   "outputs": [],
   "source": [
    "bs = 64\n",
    "\n",
    "l8 = np.array(0)\n",
    "eights_dataset = [[torch.from_numpy(e.astype(np.float32)).unsqueeze(0), torch.from_numpy(l8.astype(np.int64))] for e in eights]\n",
    "l1 = np.array(1)\n",
    "ones_dataset = [[torch.from_numpy(e.astype(np.float32)).unsqueeze(0), torch.from_numpy(l1.astype(np.int64))] for e in ones]\n",
    "train_dataset = eights_dataset[1000:] + ones_dataset[1000:]\n",
    "test_dataset = eights_dataset[:1000] + ones_dataset[:1000]\n",
    "\n",
    "train_loader = torch.utils.data.DataLoader(train_dataset,\n",
    "    batch_size=bs, shuffle=True)\n",
    "test_loader = torch.utils.data.DataLoader(test_dataset,\n",
    "    batch_size=bs, shuffle=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "LVzpT2LvHo3x"
   },
   "source": [
    "You need now to code the training loop. Store the loss and accuracy for each epoch."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "jsu7KRMIHo3y"
   },
   "outputs": [],
   "source": [
    "def train(model,data_loader,loss_fn,optimizer,n_epochs=1):\n",
    "    model.train(True)\n",
    "    loss_train = np.zeros(n_epochs)\n",
    "    acc_train = np.zeros(n_epochs)\n",
    "    for epoch_num in range(n_epochs):\n",
    "        running_corrects = 0.0\n",
    "        running_loss = 0.0\n",
    "        size = 0\n",
    "\n",
    "        for data in data_loader:\n",
    "            inputs, labels = data\n",
    "            bs = labels.size(0)\n",
    "            outputs = model(inputs)\n",
    "            loss = loss_fn(outputs,labels)\n",
    "            optimizer.zero_grad()\n",
    "            loss.backward()\n",
    "            optimizer.step()\n",
    "            _,preds = torch.max(outputs,1)\n",
    "            running_corrects += torch.sum(preds == labels)\n",
    "            running_loss += loss.data\n",
    "            size += bs\n",
    "        epoch_loss = running_loss.item() / size\n",
    "        epoch_acc = running_corrects.item() / size\n",
    "        loss_train[epoch_num] = epoch_loss\n",
    "        acc_train[epoch_num] = epoch_acc\n",
    "        print('Train - Loss: {:.4f} Acc: {:.4f}'.format(epoch_loss, epoch_acc))\n",
    "    return loss_train, acc_train"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "5Es_nmD2Ho34"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Train - Loss: 0.0059 Acc: 0.8967\n",
      "Train - Loss: 0.0017 Acc: 0.9762\n",
      "Train - Loss: 0.0009 Acc: 0.9859\n",
      "Train - Loss: 0.0007 Acc: 0.9897\n",
      "Train - Loss: 0.0005 Acc: 0.9905\n",
      "Train - Loss: 0.0005 Acc: 0.9913\n",
      "Train - Loss: 0.0004 Acc: 0.9921\n",
      "Train - Loss: 0.0004 Acc: 0.9924\n",
      "Train - Loss: 0.0004 Acc: 0.9932\n",
      "Train - Loss: 0.0003 Acc: 0.9938\n"
     ]
    }
   ],
   "source": [
    "conv_class = classifier()\n",
    "# choose the appropriate loss\n",
    "loss_fn = nn.NLLLoss()\n",
    "# your SGD optimizer\n",
    "learning_rate = 1e-3\n",
    "optimizer_cl = torch.optim.Adam(conv_class.parameters(),lr=learning_rate)\n",
    "# and train for 10 epochs\n",
    "l_t, a_t = train(conv_class,train_loader,loss_fn,optimizer_cl,n_epochs = 10)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "JPG9BbRKHo39"
   },
   "source": [
    "Let's learn for 10 more epochs"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "80ABV57nHo3-"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Train - Loss: 0.0003 Acc: 0.9943\n",
      "Train - Loss: 0.0003 Acc: 0.9948\n",
      "Train - Loss: 0.0003 Acc: 0.9952\n",
      "Train - Loss: 0.0003 Acc: 0.9955\n",
      "Train - Loss: 0.0002 Acc: 0.9958\n",
      "Train - Loss: 0.0002 Acc: 0.9957\n",
      "Train - Loss: 0.0002 Acc: 0.9966\n",
      "Train - Loss: 0.0002 Acc: 0.9959\n",
      "Train - Loss: 0.0002 Acc: 0.9969\n",
      "Train - Loss: 0.0002 Acc: 0.9967\n"
     ]
    }
   ],
   "source": [
    "l_t1, a_t1 = train(conv_class,train_loader,loss_fn,optimizer_cl,n_epochs = 10)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "P960YqN0Ho4J"
   },
   "source": [
    "Our network seems to learn but we now need to check its accuracy on the test set."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "f_ttkHKAHo4K"
   },
   "outputs": [],
   "source": [
    "def test(model,data_loader):\n",
    "    model.train(False)\n",
    "\n",
    "    running_corrects = 0.0\n",
    "    running_loss = 0.0\n",
    "    size = 0\n",
    "\n",
    "    for data in data_loader:\n",
    "        inputs, labels = data\n",
    "            \n",
    "        bs = labels.size(0)\n",
    "        outputs = model(inputs)\n",
    "        loss = loss_fn(outputs,labels)\n",
    "            \n",
    "        _,preds = torch.max(outputs,1)\n",
    "        running_corrects += torch.sum(preds == labels)\n",
    "        running_loss += loss.data\n",
    "        size += bs\n",
    "\n",
    "    print('Test - Loss: {:.4f} Acc: {:.4f}'.format(running_loss / size, running_corrects.item() / size))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "nNB9RU20Ho4M"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Test - Loss: 0.0003 Acc: 0.9940\n"
     ]
    }
   ],
   "source": [
    "test(conv_class,test_loader)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "1ZUVmjBOHo4O"
   },
   "source": [
    "Change the optimizer to Adam."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "eqLRDPTxHo4P"
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "VnXvEogNHo4S"
   },
   "source": [
    "How many parameters did your network learn?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "Qd5JSwZDHo4S"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "80"
      ]
     },
     "execution_count": 60,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "8*3*3+8"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "258"
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "128*2+2"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "lfxpzNo8Ho4U"
   },
   "source": [
    "You can see them as follows:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "XkpdG05OHo4U"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "weights : tensor([[[[-0.5048,  0.3151,  0.3142],\n",
      "          [ 0.4089,  0.1618,  0.3366],\n",
      "          [ 0.4699,  0.2680,  0.0147]]],\n",
      "\n",
      "\n",
      "        [[[ 0.6346,  0.2636, -0.1966],\n",
      "          [ 0.4201,  0.3466, -0.5789],\n",
      "          [ 0.7479, -0.1116, -0.7672]]],\n",
      "\n",
      "\n",
      "        [[[ 0.6826,  0.5305,  0.3591],\n",
      "          [ 0.4304,  0.3109, -0.6487],\n",
      "          [ 0.3061,  0.7204, -0.8857]]],\n",
      "\n",
      "\n",
      "        [[[-0.6559,  0.2383,  0.2488],\n",
      "          [-0.2215,  0.4345,  0.0764],\n",
      "          [ 0.3258,  0.2525, -0.8002]]],\n",
      "\n",
      "\n",
      "        [[[-0.3310,  0.2065,  0.4321],\n",
      "          [ 0.3220,  0.3637,  0.4893],\n",
      "          [ 0.1649,  0.4655,  0.2450]]],\n",
      "\n",
      "\n",
      "        [[[ 0.5201,  0.0063, -0.3946],\n",
      "          [ 0.2872, -0.1232, -0.2125],\n",
      "          [ 0.4060,  0.2615,  0.1420]]],\n",
      "\n",
      "\n",
      "        [[[ 0.4469, -0.1928, -0.6096],\n",
      "          [ 0.5697, -0.0204, -0.2276],\n",
      "          [ 0.1247,  0.5088,  0.5519]]],\n",
      "\n",
      "\n",
      "        [[[ 0.6056,  0.5981,  0.6663],\n",
      "          [ 0.0866,  0.0288,  0.3901],\n",
      "          [-0.6272, -0.9595, -0.1036]]]])\n",
      "bias : tensor([ 0.0027, -0.3860,  0.3302, -0.5912, -0.1698, -0.4829, -0.2569, -0.3448])\n",
      "weights : tensor([[-1.4823e-01,  1.7083e-01, -9.6779e-02, -2.9050e-01,  7.0502e-02,\n",
      "         -7.6716e-02, -3.3030e-02,  2.3416e-01,  1.5542e-01, -1.3372e-01,\n",
      "         -1.4208e-01, -2.6121e-01, -2.1870e-01, -9.1847e-02,  1.5350e-01,\n",
      "         -1.6182e-02,  1.9220e-01, -5.7435e-02, -1.9282e-01,  5.7465e-02,\n",
      "          1.3702e-01,  7.6172e-02, -3.1183e-01,  1.6818e-01,  2.4568e-01,\n",
      "          3.1068e-01, -2.6068e-01,  7.3897e-02, -5.8417e-02,  1.5728e-01,\n",
      "          3.9358e-01,  1.0575e-01, -2.2816e-01, -2.2553e-01, -2.8688e-01,\n",
      "         -2.5349e-01, -1.3637e-01,  1.6962e-01, -1.6846e-01,  1.2405e-01,\n",
      "         -1.6744e-01,  1.7408e-01, -5.8435e-02, -3.8885e-02, -3.5110e-01,\n",
      "         -1.4282e-01,  2.2349e-01, -2.8617e-01,  2.7558e-01,  4.3696e-03,\n",
      "          1.7002e-01,  5.4513e-02,  1.6245e-01,  9.1823e-02,  9.3315e-01,\n",
      "          3.5788e-01,  1.5987e-01,  6.4027e-01,  3.9081e-01,  1.2685e-01,\n",
      "          2.0807e-02,  3.2188e-01,  5.2280e-01,  1.4300e-01,  8.1689e-02,\n",
      "          1.5808e-01, -8.0422e-02, -8.4184e-02,  2.9843e-02, -1.4958e-01,\n",
      "         -1.8257e-01,  1.0431e-01,  2.5289e-01, -1.0018e-01, -4.9180e-03,\n",
      "         -1.8525e-01,  4.0494e-02, -4.1892e-02,  4.9097e-02,  5.5766e-02,\n",
      "          1.7726e-01,  3.4210e-01, -1.8456e-02,  1.0479e-01,  1.2867e-01,\n",
      "          3.2346e-01, -5.9563e-02,  3.4094e-01,  6.0465e-02,  3.3748e-01,\n",
      "          2.1449e-02,  2.5684e-01,  5.6249e-02,  4.3542e-01,  7.7913e-02,\n",
      "          1.8715e-01,  7.1511e-02,  1.8760e-01,  1.0176e-01,  5.5199e-02,\n",
      "          3.1183e-01,  5.1521e-01,  1.2666e-01,  4.4630e-01, -1.5506e-01,\n",
      "          3.5585e-01, -2.0446e-02,  8.5687e-02, -1.2433e-01,  5.3954e-01,\n",
      "         -3.9790e-02,  3.6472e-02,  5.3306e-02, -4.6575e-02,  6.3599e-01,\n",
      "          1.9251e-01,  8.2641e-02,  3.6011e-01,  6.1428e-01,  1.6389e-01,\n",
      "          1.3518e-01,  5.8280e-01,  6.0775e-01, -6.2713e-02, -7.6712e-02,\n",
      "          8.6863e-02,  8.8089e-02, -4.7257e-02],\n",
      "        [ 1.4421e-01, -8.9444e-02, -5.7860e-02,  2.4903e-01, -1.7625e-01,\n",
      "         -1.1541e-02,  6.7319e-02, -2.0089e-01, -9.1887e-02,  1.3628e-01,\n",
      "          8.3010e-03,  1.7331e-01,  1.6063e-01,  7.6741e-02, -2.1200e-01,\n",
      "          1.7642e-02, -1.1034e-01,  8.6013e-02,  2.2839e-01, -5.6546e-02,\n",
      "         -1.2578e-01, -1.4665e-01,  3.0655e-01, -1.8491e-01, -1.7995e-01,\n",
      "         -1.5294e-01,  2.9171e-01, -6.8859e-02,  5.4813e-02, -1.6329e-02,\n",
      "         -3.1552e-01, -1.7627e-01,  2.1007e-01,  2.8126e-01,  2.5379e-01,\n",
      "          3.6325e-01,  1.8322e-01, -2.5833e-01,  2.4311e-01, -2.0519e-01,\n",
      "          1.7743e-01, -1.0893e-01,  8.4172e-02,  1.1286e-01,  3.2829e-01,\n",
      "          1.5839e-01, -2.4197e-01,  2.8183e-01, -2.2019e-01,  8.3815e-02,\n",
      "         -1.5031e-01, -1.1402e-01, -2.2901e-01, -2.4902e-01, -8.9722e-01,\n",
      "         -3.8644e-01, -2.5018e-01, -7.5220e-01, -4.2107e-01, -7.7528e-03,\n",
      "         -1.0321e-01, -3.3216e-01, -3.8770e-01, -2.6401e-01, -5.8289e-02,\n",
      "         -1.4192e-01, -8.1558e-03,  1.6661e-01, -1.3621e-01,  1.7943e-01,\n",
      "          2.0728e-01, -1.2117e-01, -1.4960e-01,  4.0825e-02,  1.2021e-02,\n",
      "          1.9016e-01,  3.1215e-02,  2.5353e-02, -3.3130e-02, -1.7778e-01,\n",
      "         -1.4340e-01, -3.4045e-01, -9.9676e-02, -1.0116e-01, -2.4706e-01,\n",
      "         -2.8416e-01,  1.5629e-01, -3.4479e-01, -9.7626e-02, -3.9358e-01,\n",
      "          1.2634e-01, -2.3893e-01, -1.3983e-01, -4.2385e-01, -2.1087e-01,\n",
      "         -1.1941e-01, -7.1915e-02, -1.9471e-01, -2.0288e-01, -1.3865e-01,\n",
      "         -3.0648e-01, -5.1879e-01, -1.5458e-01, -3.5980e-01,  2.3096e-01,\n",
      "         -2.6230e-01,  5.7452e-04, -1.2919e-01,  1.3760e-01, -4.6514e-01,\n",
      "          4.2435e-02,  6.9725e-02, -1.5841e-01,  7.4220e-02, -7.4971e-01,\n",
      "         -2.0843e-01, -1.0786e-01, -4.2926e-01, -5.2266e-01, -2.7721e-01,\n",
      "         -1.9316e-01, -5.5701e-01, -5.1529e-01, -3.5950e-04,  1.7086e-01,\n",
      "         -2.1767e-01, -7.1850e-02,  6.3593e-02]])\n",
      "bias : tensor([-0.0902,  0.0954])\n"
     ]
    }
   ],
   "source": [
    "for m in conv_class.children():\n",
    "    print('weights :', m.weight.data)\n",
    "    print('bias :', m.bias.data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "rjXp3y5HHo4W"
   },
   "outputs": [],
   "source": [
    "for m in conv_class.children():\n",
    "    T_w = m.weight.data.numpy()\n",
    "    T_b = m.bias.data.numpy()\n",
    "    break"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "S-g2xTm-Ho4X"
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAA8gAAACOCAYAAADtuyHuAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/P9b71AAAACXBIWXMAAA9hAAAPYQGoP6dpAAARe0lEQVR4nO3dX2iW5/3H8Y9/mvgv6qRo54zYkzFGh4OuiuuQDmTSsQ3HDno0pAcdD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AAAAEkMyAAAAJBkFgPy6dOn89WvfjWbN2/OkiVL8utf/7oHx6LfdK1L27q0rUnXurStS9u6tF18ZjwgT0xMZPv27Tl69GgvzkNLdK1L27q0rUnXurStS9u6tF18ls/0HR599NE8+uijvTgLLdK1Lm3r0rYmXevSti5t69J28ZnxgDxTk5OTmZycnH752rVrvd6SPtC1Lm3r0rYmXevSti5t69J24ev5L+kaGRnJunXrph/Dw8O93pI+0LUubevStiZd69K2Lm3r0nbh6/mAfOTIkVy9enX6MTo62ust6QNd69K2Lm1r0rUubevSti5tF76e/4j14OBgBgcHe70NfaZrXdrWpW1NutalbV3a1qXtwuf/QQYAAIDM4jvI169fzxtvvDH98ptvvpnz589nw4YN2bp1a1cPR//oWpe2dWlbk651aVuXtnVpu/jMeED+3e9+ly9+8YvTLx8+fDhJsn///hw7dqxrB6O/dK1L27q0rUnXurStS9u6tF18ZjwgP/LII2maphdnoUW61qVtXdrWpGtd2talbV3aLj7+DTIAAADEgAwAAABJDMgAAACQxIAMAAAASQzIAAAAkMSADAAAAEkMyAAAAJDEgAwAAABJDMgAAACQJFne1sYrV67MypUr29o+69evb23vjvPnz7e6/82bN7u+5vbt27N27dqur3u3nnrqqdb27njrrbda3X9qaqon6165ciWTk5M9Wftu7N69u7W9O/7617+2un/TND1Z92tf+1pWr17dk7XvRtvXTJJ873vfa3X/Xly3ly5dyqpVq7q+7t36zGc+09reHX/5y19a3f/GjRs9WfdjH/tY1qxZ05O178bnP//51vbuuHLlSqv796rtqVOnWv36eN++fa3t3TEwMNDq/uPj4/nZz37W9XV//vOfZ9myZV1f9261PXck7X+d/s4779zV2/kOMgAAAMSADAAAAEkMyAAAAJDEgAwAAABJDMgAAACQxIAMAAAASQzIAAAAkMSADAAAAEkMyAAAAJDEgAwAAABJDMgAAACQxIAMAAAASWY4II+MjOShhx7K0NBQNm7cmH379uW1117r1dnoI23r0rYmXevSti5ta9K1Lm0XpxkNyKdOncqBAwfy6quv5sUXX8y7776bL33pS5mYmOjV+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I9dKlS7vytzFr165d1H9IOub6PKxbt64r5+hW10Tbjrk8D93qmmjbbfPlmk3cj7ttvrR1zXaf+3Fd1drq+p75cj9OtO22frT1S7oAAAAgBmQAAABIsgAH5MHBwTz55JMZHBxs+yitqvg8VPyYZqPi81DxY5qpis9BxY9pNio+DxU/ptmo+DxU/Jhmo9rzUO3jma2Kz0PFj2k2+vk89P2XdAEAAMB8tOC+gwwAAAC9YEAGAACAGJABAAAgiQEZAAAAkhiQAQAAIMkCHJCPHj2abdu2ZcWKFdm5c2fOnj3b9pH6amRkJA899FCGhoaycePG7Nu3L6+99lrbx5ozXWt2TbTVtq6qbRd710Tbqqp2TbTVtq5W2jYLyPHjx5uBgYHm6aefbv70pz81TzzxRLN+/frm0qVLbR+tb/bu3ds888wzzYULF5rz5883X/7yl5utW7c2169fb/tos6Zrza5No23TaFtZxba6vkfbmip2bRptm0bbytpou6AG5B07djQHDhyYfvn27dvN5s2bm5GRkRZP1a7Lly83SZpTp061fZRZ0/W/VejaNNreibZ1VWir651pW1OFrk2j7Z1oW1c/2i6YH7G+detWzp07lz179ky/bunSpdmzZ0/OnDnT4snadfXq1STJhg0bWj7J7Oh6Zwu9a6Lth9G2roXeVtcPp21NC71rou2H0baufrRdMAPy22+/ndu3b2fTpk0feP2mTZsyNjbW0qnaNTU1lUOHDuXhhx/OAw880PZxZkXX/1aha6LtnWhbV4W2ut6ZtjVV6Jpoeyfa1tWvtst7tjI9d+DAgVy4cCGvvPJK20ehi3StS9u6tK1L25p0rUvbuvrVdsEMyPfee2+WLVuWS5cufeD1ly5dyn333dfSqdpz8ODBPP/88zl9+nS2bNnS9nFmTdcPqtI10fY/aVtXlba6/jdta6rSNdH2P2lbVz/bLpgfsR4YGMiDDz6YkydPTr9uamoqJ0+ezK5du1o8WX81TZODBw/mueeey0svvZT777+/7SPNia7vqdY10bZD27qqtdX137StqVrXRNsObetqpW3Pfv1XDxw/frwZHBxsjh071vz5z39uvvWtbzXr169vxsbG2j5a33z7299u1q1b17z88svN3//+9+nHjRs32j7arOlas2vTaNs02lZWsa2u79G2popdm0bbptG2sjbaLqgBuWma5sc//nGzdevWZmBgoNmxY0fz6quvtn2kvkpyx8czzzzT9tHmRNeaXZtGW23rqtp2sXdtGm2rqtq1abTVtq422i75/40BAABgUVsw/wYZAAAAesmADAAAADEgAwAAQBIDMgAAACQxIAMAAEASAzIAAAAkMSADAABAEgMyAAAAJDEgAwAAQBIDMgAAACQxIAMAAECS5P8AxIyyIfSkFjgAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 1200x2400 with 8 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plots([T_w[i][0] for i in range(8)])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "PlvjNVKhHo4Z"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 0.0026803 , -0.385962  ,  0.3302055 , -0.5911795 , -0.16979912,\n",
       "       -0.4829387 , -0.25690213, -0.3448213 ], dtype=float32)"
      ]
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "T_b"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "XORiuyWzHo4a"
   },
   "source": [
    "[![Dataflowr](https://raw.githubusercontent.com/dataflowr/website/master/_assets/dataflowr_logo.png)](https://dataflowr.github.io/website/)"
   ]
  }
 ],
 "metadata": {
  "colab": {
   "include_colab_link": true,
   "name": "06_convolution_digit_recognizer.ipynb",
   "provenance": []
  },
  "kernelspec": {
   "display_name": "dldiy",
   "language": "python",
   "name": "dldiy"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
